Access Token

Learn how to set up access tokens in your repository.

Access tokens are an important part of using the Prismic API. Depending on your repository’s API visibility, you may need an access token to access the API.

You can change your API visibility in your repository’s Settings > API & Security > Repository security section. You’ll see three options.

  • Private API: requires an access token for any request
  • Public API for master: requires an access token to preview releases
  • Open API:_ _does not require an access token

Generate access tokens

You need to be a repository administrator to generate an access token.

If you do not have access to your repository’s settings, then contact one of your repository’s administrators to help you with this.

In your repository, go to Settings > API & Security > Generate an Access Token section. Then fill in the new configuration:

  • Application name: The display name to identify your app, For example, My Website.
  • Callback URL: Only needed if you want to enable interaction OAuth authentication. You can list several comma-separated URLs.

Click on Add this application. This will generate the token, which you can then find under the Permanent access tokens section.

Permanent access tokens view

Permanent access tokens view

By default, this token can access your master ref. To access your releases ref, create a master+releases token. You can also revoke any access tokens no longer in use.

Use an access token

To use your access token, pass it as an option to the createClient function or include it in your config file, depending on your framework.

This example shows how to add an access token to a Prismic client. Frameworks like Next.js and SvelteKit use this method.

prismicio.js
  import * as prismic from '@prismicio/client'

  export const createClient = (config = {}) => {
    const client = prismic.createClient('your-repo-name', {
+     accessToken: 'your-access-token',
    });

    return client
  };

To learn how to use the Prismic client to fetch data, visit the Fetch Data documentation for your framework: