POST
Authorization
All you need is your API key in theAuthorization header.
string
required
Bearer, a space, then your API key. You can find it in Baag App → Settings → Developers.Request Body
All you need to send is the product the buyer picked, initems:
object[]
required
The product the buyer wants. For now, it holds exactly one product.
Response
When everything goes well, you get back status201 with the link to the checkout page:
url.
Here is what happens next:
- The buyer fills in their details on the checkout page and pays.
- The checkout page shows them the result. When they’re done, they close the page. They aren’t sent back to your website.
- The order shows up in Baag App, like any other order.
The link works for 30 minutes. If the buyer doesn’t pay in time, start a new checkout. Stock is checked when you start the checkout, so a sold-out product or variant can’t be bought.
Error Responses
Invalid request
Invalid request
Returned with status
400 when a field is missing or has a wrong value, like more than one product in items or a quantity above 100. The message names the field.Variant not found
Variant not found
Returned with status You also get it when you sent a
400 when the size and color you sent don’t match any of the product’s variants. Check the spelling against the product’s variants in Get product.size or color for a product that has none. Leave them out:Product not found
Product not found
Returned with status
404 when there’s no product with this slug in your store, or it’s archived. Check the slug in All products.Sold out
Sold out
Returned with status
409 when the product, or the size and color the buyer picked, is sold out. Let the buyer know, or offer them another option.Insufficient stock
Insufficient stock
Returned with status
409 when the buyer asked for more than what’s left. The message says how many are left, so you can lower the quantity.Missing API key
Missing API key
Returned with status
401 when the request has no Authorization header. Add your key as Authorization: Bearer pk_live_xxxxxxxxx.Invalid API key
Invalid API key
Returned with status
401 when the key is wrong, or it was regenerated in Baag App. Copy your key again from Settings → Developers.Plan required
Plan required
Returned with status
403 when your store’s plan doesn’t include the API. Your key works again as soon as your store is on the Basic or Pro plan.Rate limited
Rate limited
Returned with status
429 when your key sent too many requests in a short time. Wait a moment, then try again.Internal error
Internal error
Returned with status
500 when something went wrong on Baag’s side. It’s not your fault. Wait a moment, then try again.