Skip to main content

Authentication

POST /v2/oauth/token

Returns an access token. The access token must be included in all other requests as a Bearer token. Before you begin, ensure you have a client ID and secret from Instacart. You need to pass these values in the request.

Request

When you make the request, specify the following values for Carrot Ads:

  • grant_type - The grant type must be client_credentials.
  • scope - Leave empty for all scopes, or set to connect:ian for ads only.

The Carrot Ads API uses the same authentication endpoint that you use with all Connect APIs. For more information about authentication, see Authentication.

FieldTypeRequiredDescription
client_idstringRequiredThe client ID.
client_secretstringRequiredThe client secret.
grant_typestringRequiredThe grant type.
scopestringOptionalThe APIs that this token can access. Default is all the APIs specified in the retailer application configuration.
codestringOptionalThe authorization code.
redirect_uristringOptionalThe redirect URI when the authorization code was generated.
assertionstringOptionalThe assertion.

Request examples

curl --request POST \
--url https://connect.instacart.com/v2/oauth/token \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"client_id": "string",
"client_secret": "string",
"grant_type": "string",
"scope": "string",
"code": "string",
"redirect_uri": "string",
"assertion": "string"
}'

Response

FieldTypeRequiredDescription
access_tokenstringRequiredThe token to be used to authenticate requests.
token_typestringRequiredThe token type.
expires_innumberRequiredThe number of seconds the token will expire in.
created_atnumberRequiredThe epoch time of when the token was created.
scopestringOptionalThe scope of the token.

Response examples

The following response example is a generic Connect example. For Carrot Ads, the scope returned is connect:ian.

200 Success

{
"access_token": "mhtEdMZYPypuW_I0fYken8cAqE7llDaoNefHSeVj9u4",
"token_type": "Bearer",
"expires_in": 86400,
"scope": "connect:fulfillment",
"created_at": 1603897760
}

Authentication Errors

HTTP CodeCauseErrorDescription
400Invalid authorization code or redirect URI"invalid_grant""Assertion is not provided or invalid assertion provided for the grant_type."
401Invalid client ID or secret"invalid_client""Client authentication failed due to unknown client, no client authentication included, or unsupported authentication method."
403Query Params Forbidden"query_params_forbidden""Providing OAuth credentials as query parameters may cause them to be compromised. Please reach out to Instacart's security team and have the credentials rotated."