API Reference
Get API Tokens for a user
Generate JWT with permissions
Get API Tokens
Route |
Method |
/v0/api/token |
GET |
Available parameters: - <code class="dcode">email</code>: email address of a user to get API tokens for - <code class="dcode">user_id</code>: user id of a user to get API tokens for
Example
curl -H "Authorization: Bearer <your_api_token>" https://api-dev.headspin.io/v0/api/token?email=<email_address>
curl -H "Authorization: Bearer <your_api_token>" https://{api}}/v0/api/token?user_id=<user_id>
Response
A JSON object that contains a list of API tokens along with information relevant to each API token. Example:
{
"api_tokens": [
{
"api_token": <api_token>,
"org_name": <org_name>,
"team_name": <team_name>,
"role_name": <role_name>,
},
...
]
}
Generate JWT with permissions
Route |
Method |
/v0/jwt/permissions |
POST |
Available parameters:
<code class="dcode">permissions</code>
: a list of permissions that the jwt will have access to. Passing in "<code class="dcode">_default</code>"
as the only element will default the JWT to the user's permission. Passing in no permissions will return a <code class="dcode">403</code>
error.<code class="dcode">duration</code>
: how long the JWT token will last before expiration. Omitting this parameter will default to a set time of 2 weeks. WARNING: It is not recommended to set the duration to <code class="dcode">0</code>
as it will generate a JWT that never expires which can lead to security issues.
Example
# Pass in a list of permissions
curl -X POST -H "Authorization: Bearer <your_api_token>" -H "Content-Type: application/json" https://api-dev.headspin.io/v0/jwt/permissions -d '{"permissions": [<list_of_permissions>]}'
# Pass in a duration
curl -X POST -H "Authorization: Bearer <your_api_token>" -H "Content-Type: application/json" https://api-dev.headspin.io/v0/jwt/permissions -d '{"permissions": [<list_of_permissions>], "duration": 60]}'
# Generate a JWT with the user's default set of permissions
curl -X POST -H "Authorization: Bearer <your_api_token>" -H "Content-Type: application/json" https://api-dev.headspin.io/v0/jwt/permissions -d '{"permissions": ["_default"]}'
Response
A JSON object that contains the JWT.