NAV

Introduction

As you review the Airtm Payments API documentation,
you may find helpful code samples in this column.

Use Airtm's Payments API to programtically pay and get paid using Airtm. Business enterprises use Airtm to receive payment from their users, and distribute payments in bulk or one at a time to employees, contractors and freelancers around the world.

If you haven't already, please contact our Airtm Partnerhips team to get your Airtm Enterprise Partner account set up.

Contact Airtm Partnerships Team

Once you have an Airtm Enterprise Account, you can create your API keys in your Settings.

Get your API keys

Authentication

Basic Auth

Basic Auth is synonymous with logging in via a username and password.

Every request to the Airtm API must present proper authentication credentials in order to identify the partner making the request. To authenticate, an Enterprise must transmit an HTTP Basic Authorization header where the username is the partner ID, and the password is the partner secret.

To compose this header manually, base64 encode a string conforming to the following format:

<API Key>:<secret Key>

For example, a Partner Enterprise with an ID of “123,” and who has been provisioned a secret of “abc” will base64 encode the string “123:abc” and transmit the following header:

Authorization: Basic MTIzOmFiYw==

Most API clients will take care of this encoding automatically if you select Basic Auth.

Security Considerations

Partner Enterprises should be careful to only store credentials and connect to Airtm from secured and private servers. Enterprises should not share their access credentials with anyone.

Partner Enterprises should not connect to Airtm directly from a client, as this would expose their access credentials to the public, and put their account at risk.

Hosts, Servers and Ports

Airtm supports two different environments for developers:

Sandbox Production / Live
Host https://payments.static-stg.tests.airtm.org payments.air-pay.io
Port 443 443

Callback IPs

A lot of endpoints offer callbacks to inform your app about a successful or failed operation. To make sure you can receive those callbacks, you often need to whitelist those IPs that the callbacks originate from. Here is an overview of those IPs:

Sandbox Production / Live
3.229.5.186 34.223.198.111
3.229.158.255 34.223.166.175
52.72.100.238 34.223.169.181
18.207.25.189 35.155.119.51
100.25.93.6
44.206.130.250

Rate Limit

Airtm imposes a rate limit for each Partner Enterprise. This limit is measured by requests per second. The current Rate Limit for all Partners is 10 requests/second. In the case that the limit is reached a 429 is returned.

If your use case requires a higher limit, please contact partners@airtm.com.

Headers

... are always:

Purchases / Payins

Purchases (Payins) transfer funds from your user's Airtm account to your Airtm account.

Create Purchase

Request

curl https://payments.static-stg.tests.airtm.org/purchases \
  -H "Content-Type: application/json" \
  -H "Authorization: Basic {your token}" \
  -d @- << EOF
{
  "code": "ExternalIdentifier01",
  "description": "Purchase test",
  "cancel_uri": "https://your.site/cancel",
  "confirmation_uri": "https://your.site/confirm",
  "callback_uri": "https://your.site/callback",
  "amount": 15,
  "items": [
    {
      "description": "test item 1",
      "amount": 6,
      "quantity": 2
    },
    {
      "description": "test item 2",
      "amount": 3,
      "quantity": 1
    }
  ]
}
EOF

Success Response (200)

{
  "id": "5201de5f-03e6-43e1-ba36-bebaf3f429f6",
  "status": "created",
  "amount": "15.00",
  "description": "Purchase test",
  "confirmation_uri": "https://your.site/confirm",
  "cancel_uri": "https://your.site/cancel",
  "code": "ExternalIdentifier01",
  "airtm_operation_id": null,
  "created_at": "2022-05-25T00:34:30.641Z",
  "updated_at": "2022-05-25T00:34:30.641Z",
  "airtm_user_id": null,
  "airtm_user_email": null,
  "operation_type": "purchase",
  "failure_uri": null,
  "failure_reason": null,
  "callback_uri": "https://your.site/callback",
  "airtm_operation_hash": null,
}

Error Responses

{
    "code": "352014",
    "message": "A purchase with this code already exists"
}

Update the code property in the payload to an unique value.

POST /purchases


This endpoint will allow you to create a purchase (pay-in). In order to complete a purchase, it must first be created. Then the user must be directed to the Airtm website to confirm/checkout the purchase, at which time they will be redirected to a URL of your choosing. See “Usage” below.

Usage

  1. Create a purchase via an HTTP POST.

  2. Extract the id from the response, and redirect user to: https://<API Host>/checkout/:id User will be redirected for authentication as necessary.

  3. User will confirm or cancel purchase from Airtm’s website.

  4. If confirmed, money will be transferred from user’s Airtm wallet, to partner's Airtm wallet, and redirected to the provided confirmation_uri. If cancelled, no money will be transferred, and the user will be redirected to the provided cancel_uri.

Upon confirmation, or cancellation the purchase will be considered completed, and the URL residing at /checkout/:id will no longer function. Therefore, if you wish to complete an identical purchase, you will need to create a new purchase, and be provisioned a new id for that purchase.

The confirmation_uri attribute should not be used for transaction completeness verification, if the URI was requested, it doesn't mean the transaction was completed successfully. If the callback_uri attribute is provided, we will POST the purchase JSON to it after the purchase is completed, either if it was confirmed, cancelled or failed. In case callback_uri attribute is NOT provided, we recommend checking the transaction status using GET /operations/:id before any external movement.

Request attributes

Attribute Type Description
code string An arbitrary string of the partner’s choosing. Used to identify and correlate Airtm purchases with partner records. Must be a unique.
description string A text string describing the purchase. This text is displayed to the user when they are confirming the transaction. (limit: 250 characters)
cancel_uri string (optional) A URL to redirect the user to when they cancel the transaction.
confirmation_uri string (optional) A URL to redirect the user to when they confirm the transaction.
callback_uri string (optional) An endpoint / webhook on your server which we will POST the purchase JSON to when the purchase is completed.
amount number The total amount in USD of the purchase. This value must correctly correspond to the sum of the amounts associated with each purchase item.
items Array An array of the items being purchased / bought. See the purchase item attributes table for details

We will redirect the user to either confirmation_uri or cancel_uri with code as query parameter so you can process the Purchase as being either confirmed or cancelled.

Purchase item attributes

A Purchase contains an array of Purchase Items. An individual Purchase Item describes a good or service being purchased.

Attribute Type Description
description string An arbitrary string describing the individual item.
amount number The price in USD of the individual item.
quantity number The number of items being purchased. This will be multiplied with the 'amount' value to calculate the total.

Refund Purchase

The way to emit a purchase refund is to create a payout from your Airtm Enterprise account and then commit it, this will move money from your Airtm account to your user's Airtm account.

Please read more about payouts here.

Possible statuses

This is a full list of all the possible statuses that purchases/pay-ins might have at any given moment:

Status Is it final? What does it mean?
created no The purchase was created and is awaiting action from the user
confirmed yes The purchase was successfully completed by the user and the funds have been credited to your account!
canceled yes The user canceled the purchase. No funds were transferred.
failed yes Something went wrong when the user attempted to complete or cancel the purchase. Please contact support to know the exact location of the funds.

Payments / Payouts

Payments (Payouts) transfer funds from your Airtm account to your user's Airtm account.

Create Payout

Request

curl https://payments.static-stg.tests.airtm.org/payouts \
  -H "Content-Type: application/json" \
  -H "Authorization: Basic {your token}" \
  -d @- << EOF
{
  "email": "john.doe@gmail.com",
  "description": "Payout test",
  "amount": 1,
  "confirmation_uri": "http://your.site/payout/success",
  "failure_uri": "http://your.site/payout/failure"
} 

EOF

Success Response (200)

{
  "id": "57f384ac-c5f7-492a-aaf7-daa928de9b40",
  "partner_id": "2abf29df-4c6d-4de4-ae55-d26556ac5475",
  "status": "created",
  "amount": "1.00",
  "description": "Payout test",
  "confirmation_uri": "https://your.site/success",
  "cancel_uri": null,
  "failure_uri": "https://your.site/failure",
  "failure_reason": null,
  "callback_uri": null,
  "code": null,
  "airtm_operation_id": null,
  "created_at": "2019-03-05T18:48:07.000Z",
  "updated_at": "2019-03-05T18:48:07.000Z",
  "airtm_user_email": "john.doe@gmail.com",
  "airtm_user_id": "d2f17c25-4aa2-46c2-aecb-498ffdd23aa2",
  "operation_type": "payout",
  "airtm_operation_hash": null,
}

POST /payouts


Request attributes

Attribute Type Description
email string the recipient's email address that is associated to their airtm account
description string An arbitrary string describing the payment. This information is displayed to the recipient. It is recommended the string roughly summarized the purpose of the payment.
amount number The payment amount in USD.
confirmation_uri string An endpoint / webhook on your server which we will POST the payout JSON to when the payout is successfully completed
failure_uri string An endpoint / webhook on your servers which we will POST the payout JSON to when we're unable to process the payout

Response attributes

Attribute Type Description
operation_id string A unique identifier for the payment in Airtm. This value is returned in the response to creating a purchase.
status string "created"

Commit Payout

Request

curl \
  -X POST https://payments.static-stg.tests.airtm.org/payouts/57f384ac-c5f7-492a-aaf7-daa928de9b40/commit \
  -H "Authorization: Basic {your token}"

Success Response (200)

{
  "id": "57f384ac-c5f7-492a-aaf7-daa928de9b40",
  "partner_id": "2abf29df-4c6d-4de4-ae55-d26556ac5475",
  "status": "COMPLETED",
  "amount": "1.00",
  "description": "Payout test",
  "confirmation_uri": "https://your.site/success",
  "cancel_uri": null,
  "failure_uri": "https://your.site/failure",
  "failure_reason": null,
  "callback_uri": null,
  "code": null,
  "airtm_operation_id": "a8bc79c2-cde3-4906-b3f5-5af028b3a57e",
  "created_at": "2019-03-05T18:48:07.000Z",
  "updated_at": "2019-03-05T18:48:21.000Z",
  "airtm_user_email": "john.doe@gmail.com",
  "airtm_user_id": "d2f17c25-4aa2-46c2-aecb-498ffdd23aa2",
  "operation_type": "payout",
  "airtm_operation_hash": "4AA2FV46C2CDAECB"
}

Error Responses

POST /payouts/:id/commit


After calling this endpoint, Airtm will try to move the money from your account to the user's.

After finishing, the status of the payout will be completed (or failed in case of failure), which you can find out by calling /operations/:id

One-Step Payout

POST /payouts/one-step


If you want to do a payout in just one API call (instead of a two-step process outlined in Create / Commit Payout), you can now use this one-step endpoint.

The usage is exactly the same as the "create payout" endpoint at POST /payouts with the only difference being that the second step (commit payout) will immediately be executed and there is no need to make a call to the commit endpoint.

so, simply put:

(POST /payouts/one-step) = (POST /payouts) + (POST /payouts/:id/commit)

Possible statuses

This is a full list of all the possible statuses that payouts might have at any given moment:

Status Is it final? What does it mean?
created no The payout was created and is awaiting you to call the commit endpoint
pending no Funds have been placed in an escrow and are awaiting the recipient to sign up to Airtm in order to receive them
completed yes The payout has been completed successfully, funds have been credited to the customer's account!
canceled yes (Only applies if the payout was previously pending) Payout has been canceled and funds have been returned to your account
failed yes Something went wrong when we attempted to process the payout. Please contact support to know the exact location of the funds.

Operations

Operations are transactions related to movements of funds between Airtm accounts.

List Operations

Request

curl https://payments.static-stg.tests.airtm.org/operations \
  -H "Authorization: Basic {your token}"

Success Response (200)

{
  "currentPage": 1,
  "lastPage": 5,
  "perPage": 5,
  "total": 25,
  "from": 1,
  "to": 5,
  "data": [
    {
      "id": "5201de5f-03e6-43e1-ba36-bebaf3f429f6",
      "status": "created",
      "amount": "15.00",
      "description": "Purchase test",
      "confirmation_uri": "https://your.site/confirm",
      "cancel_uri": "https://your.site/cancel",
      "code": "ExternalIdentifier01",
      "airtm_operation_id": null,
      "created_at": "2022-05-25T00:34:30.641Z",
      "updated_at": "2022-05-25T00:34:30.641Z",
      "airtm_user_id": null,
      "airtm_user_email": null,
      "operation_type": "purchase",
      "failure_uri": null,
      "failure_reason": null,
      "callback_uri": "https://your.site/callback",
      "airtm_operation_hash": null
    },
    {
      "id": "57f384ac-c5f7-492a-aaf7-daa928de9b40",
      "partner_id": "2abf29df-4c6d-4de4-ae55-d26556ac5475",
      "status": "created",
      "amount": "1.00",
      "description": "Payout test",
      "confirmation_uri": "https://your.site/success",
      "cancel_uri": null,
      "failure_uri": "https://your.site/failure",
      "failure_reason": null,
      "callback_uri": null,
      "code": null,
      "airtm_operation_id": null,
      "created_at": "2019-03-05T18:48:07.000Z",
      "updated_at": "2019-03-05T18:48:07.000Z",
      "airtm_user_email": "john.doe@gmail.com",
      "airtm_user_id": "d2f17c25-4aa2-46c2-aecb-498ffdd23aa2",
      "operation_type": "payout",
      "airtm_operation_hash": null,
    },
    ...
  ]
}

GET /operations


Request schema

Parameter Type Description
page numeric The page number requested. Default: 1.
perPage numeric The number of operations to return in each request. Default: 10.
type string Filter just for an specific payment type. May be payout or purchase

Operation Schema

An operation is an abstraction of the more specific entities: purchase and payout. Operations are used when referring to all of the transactions within an account. This schema also applies to the other responses under /operations

Attributes

Attribute Type Description
status string The status of the operation, please refer to this list for the possible statuses of purchases and this other list for the statuses of payouts
description string(250) A text string describing the purchase. This text is displayed to the user when they are confirming the transaction.
amount numeric The payment amount in USD.
id string Payment unique identifier
airtm_user_email string The ID of the user involved in the payout/purchase
airtm_operation_id string The ID of the operation on Airtm platform
operation_type string One of the following values ("purchase", "payout")
partner_id uuid The ID of the partner who created/initiated the operation.
confirmation_uri string An available URL on partner's servers to redirect (purchase) or POST (payout) to, when the payment is completed
cancel_uri string An available URL on partner's servers to redirect the user to when they cancel a purchase
failure_uri string An available URL on partner's servers to POST when payout fails
created_at datetime The datetime the operation was created.
updated_at datetime The datetime the operation was last modified.

Get Operation

curl https://payments.static-stg.tests.airtm.org/operations/<id> \
  -H "Authorization: Basic {your token}"

Purchase response (200)

{
  "id": "5201de5f-03e6-43e1-ba36-bebaf3f429f6",
  "status": "created",
  "amount": "15.00",
  "description": "Purchase test",
  "confirmation_uri": "https://your.site/confirm",
  "cancel_uri": "https://your.site/cancel",
  "code": "ExternalIdentifier01",
  "airtm_operation_id": null,
  "created_at": "2022-05-25T00:34:30.641Z",
  "updated_at": "2022-05-25T00:34:30.641Z",
  "airtm_user_id": null,
  "airtm_user_email": null,
  "operation_type": "purchase",
  "failure_uri": null,
  "failure_reason": null,
  "callback_uri": "https://your.site/callback",
  "airtm_operation_hash": null
}

Payout response (200)

{
  "id": "57f384ac-c5f7-492a-aaf7-daa928de9b40",
  "partner_id": "2abf29df-4c6d-4de4-ae55-d26556ac5475",
  "status": "created",
  "amount": "1.00",
  "description": "Payout test",
  "confirmation_uri": "https://your.site/success",
  "cancel_uri": null,
  "failure_uri": "https://your.site/failure",
  "failure_reason": null,
  "callback_uri": null,
  "code": null,
  "airtm_operation_id": null,
  "created_at": "2019-03-05T18:48:07.000Z",
  "updated_at": "2019-03-05T18:48:07.000Z",
  "airtm_user_email": "john.doe@gmail.com",
  "airtm_user_id": "d2f17c25-4aa2-46c2-aecb-498ffdd23aa2",
  "operation_type": "payout",
  "airtm_operation_hash": null,
}

GET /operations/:id


This endpoint will return an operation corresponding to the specified ID.

Fields may differ depending on operation_type field, which can be purchase or payout.

See Operation Schema for details

Partner

Get partner information

Get infromation related to your Partner Enterprise account, including current balance.

Request

curl https://payments.static-stg.tests.airtm.org/partners/me \
  -H "Authorization: Basic {your token}"

Success Response (200)

{
  "email": "john@acme.com",
  "id": "53f2349-23r2-523w-ba421-1f23422d42",
  "name": "John Doe",
  "currency": "USD",
  "balance": 1023.45
}

GET /partners/me


This endpoint returns infromation related to your Partner Enterprise account, including current balance.

Response attributes

Attribute Type Description
email string The email/username of the partner.
id string The partner’s unique ID.
name string The partner’s display name.
currency string The currently their balance is denominated in.
balance numeric The partner’s account balance.

Bulk Payments

Issue bulk payments (payouts) to be processed in a single request.

New bulk payment

Request

curl \
-X POST https://payments.static-stg.tests.airtm.org/bulk-payments \
-H "Authorization: Basic {your token}"
  -d @- << EOF
[
  {
    "receiver_email": "patrick@airtm.io",
    "amount": 10,
    "currency": "USD",
    "note": "salary",
    "internal_note": "system number 12345-235"
  },
  {
    "receiver_email": "master@airtm.io",
    "amount": 10,
    "currency": "USD",
    "note": "salary",
    "internal_note": "system number 45113-231"
  }
]
EOF

Success Response (200)

{
  "id": "938ab3e6-a8f7-4995-bb23-a09703fc3289",
  "status": "PENDING",
  "payments": {
    "count": 2
  }
}


Error Responses

{
    "message": "user needs 9713 more USD to fulfill all payments."
}
{
    "message": "sender does not have a valid account status (currently BANNED)"
}

POST /bulk-payments


You will receive a response with the id of your bulk payment and the processing will start asynchronously after you receive your response.

You can check in with the progress of your ongoing bulk payment with any of the endpoints described further down this page.

Every request needs to consist of payments that have these required parameters:

Parameter Description
receiver_email The email address associated with the Airtm account belonging to who you send this money to. You can send to any email but if they do not have an Airtm account, they need to sign up with exactly that email to claim their money.
amount The amount of money you want to send down to two floating points
currency A string representing the currency you want to send in (Currently we only support 'USD' for AirUSD, any other currency will be rejected)
note A string that will be added as a note to your transaction for the recipient to see
internal_note An internal note for yourself, like a comment or a system number for your internal softwawre

details by id

Request

 https://payments.static-stg.tests.airtm.org/bulk-payments/7fc5b130-e65f-4a19-9073-f3e7bdde1c2a/payments

Success Response (200)

{
  "id": "7fc5b130-e65f-4a19-9073-f3e7bdde1c2a",
  "status": "RUNNING",
  "payments": {
    "count": 2
  }
}

GET /bulk-payments/:id


get the details of your existing bulk payment.

The status "RUNNING" is the default after you have posted your bulk payment. It means that the individual payments are being processed and not all of them have processed yet.

Once that has happened, the status will switch to "DONE".

failed payments by id

request example url

 https://payments.static-stg.tests.airtm.org/bulk-payments/7fc5b130-e65f-4a19-9073-f3e7bdde1c2a/errors

Response if everything went fine

{
  "payments": [],
  "count": 0,
  "pages": 0,
  "currentPage": 1,
  "status": "FAILED"
}

Response if some payments failed

{
  "payments": [
    {
      "receiver_email": "aldo@airtm.io",
      "amount": 10,
      "currency": "USD",
      "note": "salary",
      "internal_note": "best",
      "status": "FAILED",
      "error": "error 052108 - please contact support"
    },
    {
      "receiver_email": "felix@airtm.io",
      "amount": 10,
      "currency": "USD",
      "note": "salary",
      "internal_note": "best",
      "status": "FAILED",
      "error": "The second party is not allowed to receive more money"
    }
  ],
  "count": 2,
  "pages": 1,
  "currentPage": 1
}

GET /bulk-payments/:id/errors


This endpoint allows you to see the parts of your bulk payment that could not be processed. There is no way to re-start them other than to create a new bulk payment.

Possibly some errors may not be clear or only contain an error code. Please reach out to partners@airtm.com, we are eager to improve the API or explain why a payment cannot be processed.

This endpoint is paginated, so make sure to "flip through the pages" via the query parameter "page" if you need to get all the information

bulk payments history

request example url

 https://payments.static-stg.tests.airtm.org/bulk-payments?page=1

Success Response (200)

{
  "bulk_payments": [
    {
      "id": "7fc5b130-e65f-4a19-9073-f3e7bdde1c2a",
      "status": "DONE",
      "created_at": "2021-06-25T23:22:47.415Z",
      "payments": {
        "count": 2,
        "completed": 2,
        "errored": 0
      }
    },
    {
      "id": "16872319-fdf8-42ff-bf1d-6f5d83d0ec63",
      "status": "DONE",
      "created_at": "2021-06-25T19:53:56.978Z",
      "payments": {
        "count": 713,
        "completed": 713,
        "errored": 0
      }
    },
    {
      "id": "3d2f2c20-0590-4df5-beb7-acaf76339122",
      "status": "DONE",
      "created_at": "2021-06-25T19:53:44.428Z",
      "payments": {
        "count": 5,
        "completed": 5,
        "errored": 0
      }
    },
    {
      "id": "79146ce5-a16f-47d3-99cb-d7b4d137d629",
      "status": "DONE",
      "created_at": "2021-06-25T14:43:12.801Z",
      "payments": {
        "count": 4,
        "completed": 2,
        "errored": 2
      }
    },
    {
      "id": "47b08782-20c1-4c8e-b7a5-1ca0b046af08",
      "status": "DONE",
      "created_at": "2021-06-25T14:31:24.549Z",
      "payments": {
        "count": 4,
        "completed": 4,
        "errored": 0
      }
    }
  ],
  "count": 5,
  "pages": 1,
  "currentPage": 1
}

GET /bulk-payments?page=1


get all bulk payments associated with your account. This will give you an overview of all the bulk payments you ever posted.

This endpoint is paginated, so make sure to "flip through the pages" via the query parameter "page" if you need to get all the information.

all payments by id

request example url

curl \
  -H "Authorization: Basic {your token}" \
  "https://payments.static-stg.tests.airtm.org/bulk-payments/7fc5b130-e65f-4a19-9073-f3e7bdde1c2a/payments?page=1&sort=desc:amount,asc:internal_note"

Success Response (200)

{
  "payments": [
    {
      "receiver_email": "alberto@airtm.io",
      "amount": 10,
      "currency": "USD",
      "note": "salary",
      "internal_note": "system number 12345-235",
      "status": "COMPLETED"
    },
    {
      "receiver_email": "patrick@airtm.io",
      "amount": 10,
      "currency": "USD",
      "note": "salary",
      "internal_note": "system number 32452-234",
      "status": "PENDING"
    },
    {
      "receiver_email": "master@airtm.io",
      "amount": 10,
      "currency": "USD",
      "note": "salary",
      "internal_note": "system number 45113-231",
      "status": "COMPLETED"
    }
  ],
  "count": 3,
  "pages": 1,
  "currentPage": 1
}

GET /bulk-payments/:id/payments?page=1&sort=desc:amount,asc:internal_note


get the status of all payments in an existing bulk payment of yours. This will allow you to find out which payments succeeded, are still pending or may have failed.

This endpoint is paginated, so make sure to "flip through the pages" via the query parameter "page" if you need to get all the information.

You can sort the payment items using any their parameters with the query parameter "sort" in the format <direction>:<parameter>. You can use multiple sorting parameters in the same format separated with a comma.

Sorting Directions Description
asc Ascending order
desc Descending order

Possible statuses

This is a full list of all the possible statuses that bulk payments might have at any given moment:

Status Is it final? What does it mean?
pending no the bulk payment was received but it has yet to be started
running no Our system is currently processing all the individual payments contained in this bulk payment
done yes this doesn't mean all payments were completed successfuly, it may have guest or failed Payment Items. Tasks with status = 'DONE' mean only that the processing, validations and creation of operations related to that task is completed.
failed yes Something went wrong when processing one or more individual payments. Please check the errors endpoint to know what happened and contact support if necessary

Keep in mind individual payment items inside a bulk payment can have different statuses:

Status Is it final? What does it mean?
queued no The payment has been queued and is awaiting its turn to be processed
pending no Funds have been placed in an escrow and are awaiting the recipient to sign up to Airtm in order to receive them
completed yes The payment has been completed successfully, funds have been credited to the customer's account!
canceled yes (Only applies if the payment was previously pending) payment has been canceled and funds have been returned to your account
failed yes Something went wrong when we attempted to process the payment. Please check the errors endpoint to know what happened and contact support if necessary