Skip to main content

Get a client credentials access token for the Fulfillment API

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

  1. Before you begin
  2. Generate a token
  3. Create a Connect user account

Before you begin

For this tutorial, you need the following items:

Generate a token

To make requests to the Connect APIs, you need a bearer token with the client_credentials grant type. To generate the token, use the authentication endpoint and specify your client ID and secret in the body.

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:fulfillment”
}'

The response contains the generated token.

{
"access_token": "<your_access_token>",
"token_type": "Bearer",
"expires_in": 86400,
"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.

Create a Connect user account

To validate that your token works, try creating a Connect user account. Your site creates a user account to associate with a customer's order. All requests require the generated access token and an HTTPS call that contains the Instacart development server domain.

curl --request POST \
--url 'https://<instacart_development_domain>/v2/fulfillment/users' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <your_access_token>' \
--header 'Content-Type: application/json' \
--data '{
"user_id": "johnsmith6000",
"first_name": "john",
"last_name": "smith",
"phone_number": "800-555-0100"
}'

A successful request returns a JSON response with a status code of 200 and the following fields:

{
"user_id": "johnsmith6000",
"first_name": "John",
"last_name": "Smith",
"phone_number": "800-555-0100"
}

You are ready to begin trying out Instacart Connect capabilities.

For more information about other responses that you might receive, see Create a Connect user account. If you receive any valid response, the token is working with the Instacart server.