Link an Instacart account
POST /v2/fulfillment/users/{user_id}/link
Links a customer's Connect user account to their Instacart account. Requires a valid linking token. After the accounts are linked, you can get Instacart account information.
Security
Name | In | Description |
---|---|---|
Authorization | header | The Authorization header with the bearer token acquired during authentication. |
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
user_id | path | string | The ID of the user. |
Request
Field | Type | Required | Description |
---|---|---|---|
linking_token | string | The linking token. |
Request examples
- cURL
- Java
- Python
- Go
curl --request POST \
--url 'https://connect.instacart.com/v2/fulfillment/users/{user_id}/link' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"linking_token": "string"
}'
HttpResponse<String> response = Unirest.post("https://connect.instacart.com/v2/fulfillment/users/{user_id}/link")
.header("Accept", "application/json")
.header("Content-Type", "application/json")
.header("Authorization", "Bearer <token>")
.body("{\n \"linking_token\": \"string\"\n}")
.asString();
import http.client
conn = http.client.HTTPSConnection("connect.instacart.com")
payload = "{\n \"linking_token\": \"string\"\n}"
headers = {
'Accept': "application/json",
'Content-Type': "application/json",
'Authorization': "Bearer <token>"
}
conn.request("POST", "/v2/fulfillment/users/{user_id}/link", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://connect.instacart.com/v2/fulfillment/users/{user_id}/link"
payload := strings.NewReader("{\n \"linking_token\": \"string\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Accept", "application/json")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response
Field | Type | Required | Description |
---|---|---|---|
success | boolean | Whether the request was successful. |
Response examples
200 Success
200
User linked
{
"success": true
}
4XX Errors
Error responses return either a single error or multiple errors.
HTTP Code | Cause | Error Message | Error Code | Error Meta |
---|---|---|---|---|
400 | User not found | "User Not Found" | 1001 | {"key":"user_id"} |
400 | Invalid linking token | "Linking token is invalid" | 1001 | {"key":"linking_token"} |
400 | Without linking token | "can't be blank" | 1001 | {"key":"linking_token"} |
400 | Instacart User already linked | "Validation failed: Common identities can only have one user per isolation context" | 1001 | {"key":"linking_token"} |
403 | User not active | "User Not Active" | null | Not applicable |