> For the complete documentation index, see [llms.txt](https://docs.logsail.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.logsail.com/api-platform/logsail-apis/api-tokens.md).

# API Tokens

Requesting authentication tokens for API access.

{% hint style="warning" %}
**Warning:** It is recommended to use a Service Account when accessing the LogSail API. Sharing email and passwords for a user account is not recommended when requesting API tokens for 3rd party access.
{% endhint %}

## Basic Authentication

API tokens for the service account can be obtained through BasicAuth flow. This flow requires the knowledge of the service account `email` and `password` which can be exchanged for a bearer token and access token set. The following API route will return a token set with the access defined in the previous section.

{% openapi src="/files/tlgXtjCUiCAFsJCHNOTT" path="<https://auth.logsail.com/users/basic/sign_in>" method="post" %}
[auth.json](https://2079904743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmZk9Jv2ufxk0FWqBkBQ3%2Fuploads%2FYvAhdMh84YQMICfu1IlW%2Fauth.json?alt=media\&token=8383f995-7a66-4464-9444-0e0d1ccf043b)
{% endopenapi %}

Within a successful response the client will have access to a `refresh_token` and `access_token`. Access tokens have an expiry time of 5 minutes and are used for all LogSail APIs. A refresh token expires in 24 hours and is rotated upon upon each refresh of an access token. The following API endpoint will rotate the token set expiring the previous token set minted.

{% openapi src="/files/tlgXtjCUiCAFsJCHNOTT" path="<https://auth.logsail.com/refresh/token>" method="post" %}
[auth.json](https://2079904743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmZk9Jv2ufxk0FWqBkBQ3%2Fuploads%2FYvAhdMh84YQMICfu1IlW%2Fauth.json?alt=media\&token=8383f995-7a66-4464-9444-0e0d1ccf043b)
{% endopenapi %}

Revoking API tokens can be done using the following API endpoint.

{% openapi src="/files/tlgXtjCUiCAFsJCHNOTT" path="<https://auth.logsail.com/refresh/revoke>" method="post" %}
[auth.json](https://2079904743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmZk9Jv2ufxk0FWqBkBQ3%2Fuploads%2FYvAhdMh84YQMICfu1IlW%2Fauth.json?alt=media\&token=8383f995-7a66-4464-9444-0e0d1ccf043b)
{% endopenapi %}
