Skip to main content

Get a client credentials access token for the Recommendations API

Learn how to authenticate with Instacart Connect and make your first Recommendations API call in a development environment.

info

Use this access token when you are calling the API from the backend.

  1. Before you begin
  2. Generate a token

Before you begin

For this tutorial, you need the following items:

  • Your client ID and secret
  • The base URL of your assigned Instacart development server

Generate a token

To make requests to the API, you need a bearer token with the client_credentials grant type. To generate the token, use the authentication endpoint, specify your client ID and secret in the body, and set the scope to connect:recommendations.

curl --request POST \
--url 'https://<instacart_development_domain>/v2/oauth/token' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"client_id": "<your_client_id>",
"client_secret": "<your_client_secret>",
"grant_type": "client_credentials"
"scope": "connect:recommendations"
}'

The response contains the generated token.

{
"access_token": "<your_access_token>",
"token_type": "Bearer",
"expires_in": 86400,
"scope": "connect:recommendations",
"created_at": 1603897760
}
note

The token is valid for 24 hours. During this period, reuse the same token in your requests. After 24 hours, you must generate a new token.