Save Shopper Context [Beta]
Save Shopper Preferences
This API describes for saving shopper preferences
Endpoint | request type | API Type |
---|---|---|
https://{{Swym API Endpoint}}/api/v3/user/save | POST | shopper |
Headers
Header | Required | Description |
---|---|---|
user-agent | Yes | User-Agent header of the app used to access the API |
origin | Yes | Origin used to access the API |
Query Params
Parameter | Type | Required | Description |
---|---|---|---|
pid | string (Encoded) | Yes | Unique identifier for the store available in Swym Admin |
Form Data
Field | Type | Required | Description |
---|---|---|---|
regid | string | Yes | Unique identifier for the shopper generated by generate-regid |
sessionid | string | Yes | Session id generated with generate-regId endpoint which does not expire without manual intervention |
language | string | Yes | Language of the shopper locale ex - en |
region | string | Yes | Region of the shopper locale ex - gb |
fname | string | optional | First name of the shopper |
lname | string | optional | Last name of the shopper |
acceptMarketing | boolean | optional | Preference to receive marketing notifications - true or false |
Example Curl
curl -X POST \
--url '{{Swym API Endpoint}}/api/v3/user/save?pid={{URL Encoded PID }}' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Accept: application/json' \
--header 'user-agent: mobileApp' \
--header 'origin: {{storeurl}}' \
--data-urlencode 'sessionid={{sessionId}}' \
--data-urlencode 'regid={{regid}}' \
--data-urlencode 'language=en' \
--data-urlencode 'region=fr' \
--data-urlencode 'fname=Swym Test User' \
--data-urlencode 'lname=Last Name' \
--data-urlencode 'acceptMarketing=true'
Curl Placeholders
Assuming these values are provided above, the curl command should work correctly. However, if there are any issues with the API endpoint or the data being passed in the request, there could still be errors that need to be resolved before you can test these APIS.
Placeholders | Descriptions |
---|---|
{{Swym API Endpoint}} | This needs to be replaced with the actual Swym API endpoint URL. |
{{URL Encoded PID}} | This needs to be replaced with the actual PID value, URL-encoded. |
{{storeurl}} | This needs to be replaced with the actual storeurl. |
{{regid}} | This needs to be replaced with the actual regid value. |
{{sessionid}} | This needs to be replaced with the actual session ID value. |
Success Response
The below responses are what you would get based on being logged in or an authenticated user.
{
"fname": "Test User",
"uid": "scPcCfdKIdvHvkDbqCimKt97byND/JALDMCYSt5GnAI=",
"em": "[email protected]",
"lname": "Support",
"pid": "E1hoZtFhNOlsZc8cZRXlKrVr1PIANUAP87ESUbBUnJg=",
"acc_mkt": true,
"prefs": {
"Mediums": {},
"Locale": {
"language": "en",
"region": "fr"
}
},
"message": "The user's preferences were saved successfully."
}
Error Response:
If the request is unsuccessful, the API will return a JSON response with an error message and an HTTP status code indicating the type of error that occurred.
Status Code | Type | Description |
---|---|---|
400 | Bad Request | Your request is invalid, change your request params and query and try again. |
401 | Unauthorised | You are performing an action on a resource that is not granted to the current logged-in user. Additionally, for REST APIs, this could mean your API key is wrong. |
403 | Forbidden | You are not allowed to request this data. |
404 | Not Found | The specified requested data could not be found. |
429 | Too Many Requests | You're raising too many requests! Slow down! |
500 | Internal Server Error -- | We had a problem with our server. Try again later. |
503 | Service Unavailable | We're temporarily offline for maintenance. Please try again later. |
Updated 6 months ago