Org API Tokens
Unit uses API Tokens to authenticate incoming requests. You can create API Tokens through Unit's Dashboard, or programmatically through an API call.
info
It is advisable that you read and understand the recommended way to use Unit's Authentication and Scopes before you create and use API tokens in your app.
Create Org API Token
Creates an Org API token.
Verb | POST |
Url | https://api.s.unit.sh/users/:userId/api-tokens |
Data Type | apiToken |
Timeout (Seconds) | 5 |
Attributes
Name | Type | Description |
---|---|---|
description | string | A description of the Org API token. |
scope | string | list of Scopes separated by spaces. |
expiration | RFC3339 Date string | Expiration date of the Org API token. |
sourceIp | string | Optional. A comma separated list of IP addresses that are allowed to use the Org API token (no spaces allowed). |
resources | Array of RestrictedResource | Optional. Restrict token to one or more specific resources. To one or many cards and/or to one or many accounts (cards under it, payments, transactions). |
curl -X POST 'https://api.s.unit.sh/users/2/api-tokens'
-H 'Content-Type: application/vnd.api+json'
-H 'Authorization: Bearer ${TOKEN}'
--data-raw '{
"data": {
"type": "apiToken",
"attributes": {
"description": "Production token",
"scope": "customers applications",
"expiration": "2022-07-01T13:47:17.000Z"
}
}
}'
Response
Response is a JSON:API document.
Example Response:
{
"data": {
"id": "19",
"type": "apiToken",
"attributes": {
"createdAt": "2021-07-01T08:51:09.108Z",
"description": "Production token",
"expiration": "2022-07-01T13:47:17.000Z",
"token": "v2.public.eyJyb2xlIjoib3JnI..."
}
}
}
List
List Org API Token resources.
Verb | GET |
Url | https://api.s.unit.sh/users/:userId/api-tokens |
Timeout (Seconds) | 5 |
curl -X GET 'https://api.s.unit.sh/users/2/api-tokens' \
-H "Authorization: Bearer ${TOKEN}"
Response
Response is a JSON:API document.
200 OK
Field | Type | Description |
---|---|---|
data | Array of APIToken | Array of org api token resources. |
Example Response:
{
"data": [
{
"id": "21",
"type": "apiToken",
"attributes": {
"createdAt": "2021-07-01T09:13:23.211Z",
"description": "Production token",
"expiration": "2022-07-01T09:13:23.124Z"
}
},
{
"id": "22",
"type": "apiToken",
"attributes": {
"createdAt": "2021-07-01T09:14:10.590Z",
"description": "Testing token",
"expiration": "2021-07-01T13:47:17.000Z",
"sourceIp": "192.168.1.1,192.168.1.2"
}
}
]
}
Revoke
Revoke an Org API Token.
Verb | DELETE |
Url | https://api.s.unit.sh/users/:userId/api-tokens/:tokenId |
Timeout (Seconds) | 5 |
Response
Response is a JSON:API document.
200 OK
Field | Type | Description |
---|---|---|
data | APIToken | The requested resource after the operation was completed. |
curl -X DELETE 'https://api.s.unit.sh/users/2/api-tokens/22' \
-H "Authorization: Bearer ${TOKEN}"