# Authenticating the API

The API key is necessary to use authenticated endpoints of our API. The API key should be included in the `Authorization` HTTP header. The key should be prefixed by the string literal `Bearer` .

For example, `Authorization`: `Bearer txn_cmp_F41bbUWxPR2FCPA3KK5t1NadFE9Ghn`.

```json
curl -X "POST" "https://api.sandbox.txn.io/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"
    }
  }
}'
```

Otherwise your will receive HTTP 401 Unauthorized:

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

To create your API keys, please refer to the [Creating your API keys](https://docs.txn.io/getting-setup/creating-your-api-keys) page in this documentation
