Skip to main content

Movements

The Movements API allows you to retrieve transaction history and movement details for user accounts. This includes filtering, pagination, and advanced querying capabilities using GraphQL.

The Movement Object

{
"id": 789012,
"amount": 10000,
"currency": "USD",
"state": "completed",
"reference": "REF-123",
"createdAt": "2024-01-15T10:30:00Z",
"completedAt": "2024-01-15T10:31:00Z",
"balanceBefore": 140000,
"balanceAfter": 150000
}

Attributes

AttributeTypeDescription
idintegerUnique identifier for the movement
amountintegerMovement amount in cents
currencystringCurrency code (USD, EUR, etc.)
statestringMovement state (pending, completed, failed, cancelled)
referencestringExternal reference or transaction ID
createdAtstringISO 8601 timestamp when movement was created
completedAtstringISO 8601 timestamp when movement was completed
balanceBeforeintegerAccount balance before the movement in cents
balanceAfterintegerAccount balance after the movement in cents

List Movements

Returns a list of movements for the authenticated user with optional filtering and pagination.

GET/movements/
curl -X GET "https://sandbox.tropipay.me/api/v3/movements/?limit=20&offset=0" \
-H "Authorization: Bearer sk_test_..."

Parameters

ParameterTypeRequiredDescription
limitintegerNoNumber of results to return (max: 50, default: 20)
offsetintegerNoNumber of records to skip (default: 0)
querystringNoJSON-encoded filter object

Query Filter Object

The query parameter accepts a JSON-encoded object with the following optional fields:

{
"state": ["completed", "pending"],
"currency": "USD",
"amountGte": 1000,
"amountLte": 100000,
"createdAtFrom": "2024-01-01T00:00:00Z",
"createdAtTo": "2024-12-31T23:59:59Z",
"reference": "REF-123"
}
FilterTypeDescription
statearrayFilter by movement states
currencystringFilter by currency
amountGteintegerMinimum amount in cents
amountLteintegerMaximum amount in cents
createdAtFromstringStart date (ISO 8601)
createdAtTostringEnd date (ISO 8601)
referencestringFilter by reference

Response

{
"items": [
{
"id": 789012,
"amount": 10000,
"currency": "USD",
"state": "completed",
"reference": "REF-123",
"createdAt": "2024-01-15T10:30:00Z",
"completedAt": "2024-01-15T10:31:00Z",
"balanceBefore": 140000,
"balanceAfter": 150000
}
],
"totalCount": 1,
"hasMore": false
}

Response Parameters

ParameterTypeDescription
itemsarrayArray of movement objects
totalCountintegerTotal number of movements matching the query
hasMorebooleanWhether there are more results available

List Account Movements

Returns movements for a specific account.

GET/accounts/{accountId}/movements
curl -X GET https://sandbox.tropipay.me/api/v3/accounts/acc_123/movements \
-H "Authorization: Bearer sk_test_..."

Parameters

Same parameters as the general movements endpoint, but filtered to the specified account.

Advanced Movements Query (GraphQL)

For complex queries and advanced filtering, use the GraphQL endpoint.

POST/movements/business
curl -X POST https://sandbox.tropipay.me/api/v3/movements/business \
-H "Authorization: Bearer sk_test_..." \
-H "Content-Type: application/json" \
-d '{
"query": "query GetMovements($filter: MovementFilter, $pagination: Pagination) { movements(filter: $filter, pagination: $pagination) { items { id amount state currency createdAt recipient { name email } sender { name email } } totalCount } }",
"variables": {
"filter": {
"state": ["completed", "pending"],
"amountGte": 100,
"amountLte": 100000,
"createdAtFrom": "2024-01-01T00:00:00Z",
"createdAtTo": "2024-12-31T23:59:59Z"
},
"pagination": {
"limit": 20,
"offset": 0
}
}
}'

GraphQL Schema

MovementFilter

input MovementFilter {
state: [MovementState!]
currency: String
amountGte: Int
amountLte: Int
createdAtFrom: DateTime
createdAtTo: DateTime
reference: String
accountId: String
}

Pagination

input Pagination {
limit: Int
offset: Int
}

Movement Type

type Movement {
id: ID!
amount: Int!
currency: String!
state: MovementState!
reference: String
createdAt: DateTime!
completedAt: DateTime
balanceBefore: Int!
balanceAfter: Int!
recipient: User
sender: User
account: Account!
}

MovementState Enum

enum MovementState {
PENDING
COMPLETED
FAILED
CANCELLED
}

GraphQL Response

{
"data": {
"movements": {
"items": [
{
"id": "789012",
"amount": 10000,
"state": "COMPLETED",
"currency": "USD",
"createdAt": "2024-01-15T10:30:00Z",
"recipient": {
"name": "John",
"email": "john@example.com"
},
"sender": {
"name": "Jane",
"email": "jane@example.com"
}
}
],
"totalCount": 1
}
}
}

Movement States

StateDescription
pendingMovement is being processed
completedMovement has been successfully completed
failedMovement failed due to an error
cancelledMovement was cancelled by user or system

Pagination

All movement endpoints support pagination using limit and offset parameters:

  • limit: Maximum number of results to return (1-50, default: 20)
  • offset: Number of records to skip (default: 0)

Example Pagination

# Get first 20 movements
curl -X GET "https://sandbox.tropipay.me/api/v3/movements/?limit=20&offset=0"

# Get next 20 movements
curl -X GET "https://sandbox.tropipay.me/api/v3/movements/?limit=20&offset=20"

Error Handling

The Movements API uses conventional HTTP response codes to indicate the success or failure of an API request.

Common Error Codes

CodeDescription
400Bad Request - Invalid query parameters
401Unauthorized - Invalid authentication
403Forbidden - Insufficient permissions
404Not Found - Account or movement doesn't exist
422Unprocessable Entity - Invalid filter parameters
429Too Many Requests - Rate limit exceeded
500Internal Server Error

Example Error Response

{
"error": {
"type": "invalid_request_error",
"code": "invalid_filter",
"message": "Invalid date format in createdAtFrom parameter",
"param": "query.createdAtFrom"
}
}

Best Practices

  1. Use pagination for large result sets to improve performance
  2. Filter by date range to limit the scope of your queries
  3. Use specific states to get only the movements you need
  4. Cache results when appropriate to reduce API calls
  5. Use GraphQL for complex queries requiring related data