User API Token

An User API Token allows you to programmatically access DRIVR APIs without needing to log in manually. This guide explains how to create a User API Token and use it to authenticate your API requests.

When accessing DRIVR through the UI or browser, users can log in using their username and password. However, for programmatic access (e.g., scripts or integrations), a User API Token is required. This token acts as a secure credential to authenticate your requests.

You can create a User API Token using the DRIVR GraphQL API ( https://{slug}.api.drivr.com/graphql, replace {slug} with your domain identifier). Follow these steps:

Run the following mutation to create a new API token:

mutation createUserApiToken{
  createUserApiToken(name: "myapitoken") {
    value
  }
}
Example Response
{
  "data": {
    "createUserApiToken": {
      "value": "YXRfZlQ3MzUzZGItN2M0ZS00NDFiLWExYjYtYWFpODI4YzcxMzRmOmtYVERnZDVqOWhaa3VLSXBBSklGSkI1WG1hZmV4dEllskE5ckljZnR2RjQ="
    }
  }
}

If you want the token to expire after a specific time, include the expiresAt parameter:

mutation {
  createUserApiToken(name: "myapitoken", expiresAt: "2030-12-31T23:59:59Z") {
    value
    expiresAt
  }
}
Example Response
{
  "data": {
    "createUserApiToken": {
      "value": "YXRfZlQ3MzUzZGItN2M0ZS00NDFiLWExYjYtYWFpODI4YzcxMzRmOmtYVERnZDVqOWhaa3VLSXBBSklGSkI1WG1hZmV4dEllskE5ckljZnR2RjQ=",
      "expiresAt": "2030-12-31T23:59:59Z"
    }
  }
}

Important Note: The token value will only be visible when it is created. Make sure to store it securely, as it cannot be retrieved later.

Once you have created a User API Token, you can use it to authenticate your API requests. The token is passed in the Authorization header as a Bearer token.

Assume you have created a token with the value YXRfZlQ3MzUzZGItN2M0ZS00NDFiLWExYjYtYWFpODI4YzcxMzRmOmtYVERnZDVqOWhaa3VLSXBBSklGSkI1WG1hZmV4dEllskE5ckljZnR2RjQ=. You can use it to query the API as follows:

curl -X POST https://{slug}.api.drivr.com/graphql \
-H "Authorization: Bearer YXRfZlQ3MzUzZGItN2M0ZS00NDFiLWExYjYtYWFpODI4YzcxMzRmOmtYVERnZDVqOWhaa3VLSXBBSklGSkI1WG1hZmV4dEllskE5ckljZnR2RjQ=" \
-d '{"query": "query { currentDomain { uuid } }"}'
Response
{"data": {"currentDomain": {"uuid": "0b6f629d-872b-48a0-9386-7c0ee61ceb0d"}}}                                                                                                               

Remember to store your tokens securely and use expiration dates for added security when needed.

User API Tokens provide a secure and convenient way to programmatically access DRIVR APIs. By following the steps in this guide, you can create and use tokens to authenticate your requests.