This is an advanced piece of documentation for developers.
To follow this article you may need experience using JavaScript, CSS and Liquid.
published February 27, 2020 | updated February 27, 2020
You can use Stockbot in a ‘headless’ manner, in this case you would have your own code to collect email addresses and phone numbers.
Sample Request
You will want to make a POST request of the following form. You must set your store’s myshopify.com domain in a X-Shopify-Domain
header so we know where your request originates from.
Here we are using CURL but you could also make requests from any language of your choice.
curl https://stockbot.oostapps.com/api/public/v1/watches
-X POST \
-H "X-Shopify-Domain: example.myshopify.com" \
-H "Accept: application/json"
The body of your request should be as follows.
{
"email": "[email protected]",
"product_id": 1111111111,
"variant_id": 1111111111,
"phone": "+44155 555 555",
"newsletter": true
}
Field Descriptions
You must provide all required fields, and should only include optional values when they have a valid value.
Field | Type | Required | Description |
---|---|---|---|
email |
string | yes | The email address to subscribe for email notifications |
product_id |
integer | yes | Product ID to make the subscription to |
variant_id |
integer | yes | Specific variant ID that is out of stock, required even if there in only one variant |
phone |
string | no | Optional phone number to subscribe to receive SMS notifications, the number must include country code |
newsletter |
string | no | Has the customer agreed to accept newsletter marketing? Defaults to false if omitted |
Sample Response
We validate data you provide and return an appropriate response. Note that if you provide incorrect product or variant ID you will still get a 200 response because we check against the Shopify API asynchronously.
200 Response
The data you sent was valid and we will attempt to subscribe the customer.
200 Done
400 Response
If you do not provide the X-Shopify-Domain
header you will receive a 400 Bad Request response.
400 Bad Request
{
"message": "You did not provide a shopify domain",
"errors": {
"X-Shopify-Domain": [
"You must provide a X-Shopify-Domain header"
]
}
}
404 Response
If you provide a shopify domain that does not have stockbot installed you will receive a 404 Not Found response.
404 Not Found
{
"message": "Shop not found"
}
422 Response
A 422 will be returned if the data provided does not match against our required formats, or a field is missing.
422 Unprocessible Entity
{
"message": "The given data was invalid.",
"errors" {
"product_id": [
"The product id field is required."
],
"variant_id": [
"The variant id field is required."
],
"phone": [
"The phone number is not a valid phone number, remember to include the country code"
],
"email": [
"The email field is required"
]
}
}
If you still need help please contact us.