Authenticating the API

Authenticating against the Txn API requires a Bearer token (API key) in the Authorization header of your API call. Supplying Bearer is a requirement when making API calls, otherwise your will receive HTTP 401 Unauthorized:

{
  "errors": [
    {
      "status": 401,
      "title": "HTTP Token: Access denied.",
      "code": "unauthorized"
    }
  ]
}

Below is an example of an API call to create an invoice.

curl -X "POST" "https://api.sandbox.txn.pro/api/public/v1/invoices" \
     -H 'Content-Type: application/vnd.api+json' \
     -H 'Authorization: Bearer txn_cmp_F41bbUWxPR2FCPA3KK5t1NadFE9Ghn' \
     -d $'{
  "data": {
    "type": "invoices",
    "attributes": {
      "amountBilled": "1000",
      "billedCurrency": "EUR",
      "chargedCurrency": "USDT",
      "network": "TTRX:USDT",
      "reference": "37ac503d-4e1f-458e-8407-033ab8bd1e5c"
    }
  }
}'

To create your API keys, please refer to the Creating your API keys page in this documentation

Last updated