--- title: Use platform token authentication slug: n3ge0020 canonical_url: https://docs.coveo.com/en/n3ge0020/ collection: apis source_format: adoc --- # Use platform token authentication Platform tokens are special [JSON web tokens](https://jwt.io/) that can be used to [query](https://docs.coveo.com/en/231/) Coveo APIs as a specific [user](https://docs.coveo.com/en/250/). You can [generate platform tokens](https://docs.coveo.com/en/6#tag/Platform-Tokens/operation/generatePlatformToken) by making a call to the Authorization Server API. ## Request a platform token To request a platform token, make a POST request to `+https://platform.cloud.coveo.com/rest/organizations//tokens+`. You must also specify a `validityPeriod` in your request, after which the token will expire. The default is 24 hours (`validityPeriod=PT24H`). You must [authenticate](https://docs.coveo.com/en/2120/) with a valid [API key](https://docs.coveo.com/en/1718/) whose [privileges](https://docs.coveo.com/en/228/) [match those needed](#get-a-list-of-privileges) for your use case. For example: * To create a platform token to perform [authenticated](https://docs.coveo.com/en/2120/) search as any [user](https://docs.coveo.com/en/250/), use an API key that was created using the **Authenticated search** [template](https://docs.coveo.com/en/1718#api-key-templates). * To create a platform token to send [Coveo Analytics data](https://docs.coveo.com/en/259/) to your [organization](https://docs.coveo.com/en/185/) as any [user](https://docs.coveo.com/en/250/), use an API key that was created using the **Usage analytics** [template](https://docs.coveo.com/en/1718#api-key-templates). To test the service on Coveo, use the [Swagger UI](https://platform.cloud.coveo.com/docs?urls.primaryName=AuthorizationServer#/Platform%20Tokens/rest_organizations_paramId_tokens_post). ## Examples . Creating a platform token to perform [authenticated](https://docs.coveo.com/en/2120/) search: ```http POST https://platform.cloud.coveo.com/rest/organizations//tokens?validityPeriod=PT24H HTTP/1.1 ​ Content-Type: application/json Accept: application/json Authorization: Bearer **********-****-****-****-************ ``` **Payload:** ```json { "body": { "additionalConfiguration": { "search": { "userIds": [ { "name": "asmith@example.com", "provider": "Email Security Provider", "type": "User" } ] } }, "organizationId": "", "privileges": [ { "level": "NORMAL", "owner": "SEARCH_API", "targetDomain": "IMPERSONATE", "targetId": "*", "type": "ENABLE" } ] } } ``` **200 OK response body:** ```json { "token": "fzKjcHdjPJKJVaJ2OjK0fzK2CI6dHJ1ZSwiZXhwIjoxNDY4Njk2NzEwLCJpYXQiOjE0lQGN..." } ``` . Creating a platform token to send [Coveo Analytics data](https://docs.coveo.com/en/259/) to your [organization](https://docs.coveo.com/en/185/): ```http POST https://platform.cloud.coveo.com/rest/organizations//tokens?validityPeriod=PT24H HTTP/1.1 ​ Content-Type: application/json Accept: application/json Authorization: Bearer **********-****-****-****-************ ``` **Payload:** ```json { "body": { "additionalConfiguration": { "analytics": { "event": { "userDisplayName": "Alice Smith", "userId": "12345678" } } }, "organizationId": "", "privileges": [ { "level": "NORMAL", "owner": "USAGE_ANALYTICS", "targetDomain": "IMPERSONATE", "targetId": "*", "type": "ENABLE" } ] } } ``` **200 OK response body:** ```json { "token": "fzKjcHdjPJKJVaJ2OjK0fzK2CI6dHJ1ZSwiZXhwIjoxNDY4Njk2NzEwLCJpYXQiOjE0lQGN..." } ``` ## Get a list of privileges To get a list of the [privileges](https://docs.coveo.com/en/228/) that you can add to your platform token, make a GET request to `+https://platform.cloud.coveo.com/rest/organizations//privileges/platformtokens+`. You must [authenticate](https://docs.coveo.com/en/2120/) with a valid [API key](https://docs.coveo.com/en/1718/) that was created using the **Custom** [template](https://docs.coveo.com/en/1718#api-key-templates) and which has the **View** [access level](https://docs.coveo.com/en/2818/) on the **Organization** [domain](https://docs.coveo.com/en/2819/).