Orders
Create order from product line items
Creates a server-side Shoppex order from product or variant line items. Use gateway to preselect a valid active gateway for the resulting pending order.
POST
/
dev
/
v1
/
orders
Create order from product line items
curl --request POST \
--url https://api.shoppex.io/dev/v1/orders \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"email": "[email protected]",
"coupon_code": "SPRING10",
"gateway": "STRIPE",
"title": "Starter Pack checkout",
"custom_fields": {
"source": "affiliate",
"campaign": "spring_launch"
},
"items": [
{
"product_id": "prod_starter",
"variant_id": "var_standard",
"quantity": 1,
"delivery_instructions": "Discord: shoppex"
}
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
email: '[email protected]',
coupon_code: 'SPRING10',
gateway: 'STRIPE',
title: 'Starter Pack checkout',
custom_fields: {source: 'affiliate', campaign: 'spring_launch'},
items: [
{
product_id: 'prod_starter',
variant_id: 'var_standard',
quantity: 1,
delivery_instructions: 'Discord: shoppex'
}
]
})
};
fetch('https://api.shoppex.io/dev/v1/orders', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.shoppex.io/dev/v1/orders"
payload = {
"email": "[email protected]",
"coupon_code": "SPRING10",
"gateway": "STRIPE",
"title": "Starter Pack checkout",
"custom_fields": {
"source": "affiliate",
"campaign": "spring_launch"
},
"items": [
{
"product_id": "prod_starter",
"variant_id": "var_standard",
"quantity": 1,
"delivery_instructions": "Discord: shoppex"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.shoppex.io/dev/v1/orders",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'email' => '[email protected]',
'coupon_code' => 'SPRING10',
'gateway' => 'STRIPE',
'title' => 'Starter Pack checkout',
'custom_fields' => [
'source' => 'affiliate',
'campaign' => 'spring_launch'
],
'items' => [
[
'product_id' => 'prod_starter',
'variant_id' => 'var_standard',
'quantity' => 1,
'delivery_instructions' => 'Discord: shoppex'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.shoppex.io/dev/v1/orders"
payload := strings.NewReader("{\n \"email\": \"[email protected]\",\n \"coupon_code\": \"SPRING10\",\n \"gateway\": \"STRIPE\",\n \"title\": \"Starter Pack checkout\",\n \"custom_fields\": {\n \"source\": \"affiliate\",\n \"campaign\": \"spring_launch\"\n },\n \"items\": [\n {\n \"product_id\": \"prod_starter\",\n \"variant_id\": \"var_standard\",\n \"quantity\": 1,\n \"delivery_instructions\": \"Discord: shoppex\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"data": {
"id": "ord_123",
"uniqid": "11111111-1111-4111-8111-111111111111",
"shop_id": "shop_1",
"customer_id": "cus_1",
"affiliate_link_id": "link_1",
"affiliate_customer_id": "cus_aff_1",
"affiliate_code": "creator123",
"affiliate_discount_amount": 3,
"customer_email": "[email protected]",
"currency": "USD",
"status": "PENDING",
"status_details": null,
"payment_status": "PENDING",
"gateway": "STRIPE",
"flow_type": "CHECKOUT",
"provider_reference": null,
"provider_reference_type": null,
"subtotal": 29.99,
"discount": 3,
"discount_display": 3,
"tax": 0,
"tax_percentage": 0,
"total": 26.99,
"total_display": 26.99,
"balance_paid_amount": 0,
"coupon_id": "coupon_spring10",
"subscription_id": null,
"custom_fields": {
"source": "affiliate",
"campaign": "spring_launch"
},
"is_developer_invoice": false,
"developer_title": null,
"checkout_url": "https://checkout.shoppex.io/invoice/11111111-1111-4111-8111-111111111111",
"items": [
{
"product_id": "prod_starter",
"product_title": "Starter Pack",
"product_type": "DIGITAL",
"variant_title": "Standard",
"quantity": 1,
"unit_price": 29.99,
"total": 29.99,
"delivery_instructions": "Discord: shoppex",
"delivery_instructions_label": "Discord username",
"delivered_items": {
"access_url": "https://downloads.example.com/starter-pack"
}
}
],
"created_at": 1711510800,
"updated_at": 1711510860
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"details": [
{
"field": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"details": [
{
"field": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"details": [
{
"field": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"details": [
{
"field": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"details": [
{
"field": "<string>",
"message": "<string>"
}
]
}
}Authorizations
Use your Shoppex API key in the Authorization header.
Body
application/jsonmultipart/form-datatext/plain
Show child attributes
Show child attributes
Response
Successful response
Show child attributes
Show child attributes
Previous
Get order detailsReturns a single Shoppex order by internal order ID or public uniqid. The response can include `custom_fields` set during invoice creation, for example `{ "source": "affiliate", "campaign": "spring_launch" }`.
Next
⌘I
Create order from product line items
curl --request POST \
--url https://api.shoppex.io/dev/v1/orders \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"email": "[email protected]",
"coupon_code": "SPRING10",
"gateway": "STRIPE",
"title": "Starter Pack checkout",
"custom_fields": {
"source": "affiliate",
"campaign": "spring_launch"
},
"items": [
{
"product_id": "prod_starter",
"variant_id": "var_standard",
"quantity": 1,
"delivery_instructions": "Discord: shoppex"
}
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
email: '[email protected]',
coupon_code: 'SPRING10',
gateway: 'STRIPE',
title: 'Starter Pack checkout',
custom_fields: {source: 'affiliate', campaign: 'spring_launch'},
items: [
{
product_id: 'prod_starter',
variant_id: 'var_standard',
quantity: 1,
delivery_instructions: 'Discord: shoppex'
}
]
})
};
fetch('https://api.shoppex.io/dev/v1/orders', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.shoppex.io/dev/v1/orders"
payload = {
"email": "[email protected]",
"coupon_code": "SPRING10",
"gateway": "STRIPE",
"title": "Starter Pack checkout",
"custom_fields": {
"source": "affiliate",
"campaign": "spring_launch"
},
"items": [
{
"product_id": "prod_starter",
"variant_id": "var_standard",
"quantity": 1,
"delivery_instructions": "Discord: shoppex"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.shoppex.io/dev/v1/orders",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'email' => '[email protected]',
'coupon_code' => 'SPRING10',
'gateway' => 'STRIPE',
'title' => 'Starter Pack checkout',
'custom_fields' => [
'source' => 'affiliate',
'campaign' => 'spring_launch'
],
'items' => [
[
'product_id' => 'prod_starter',
'variant_id' => 'var_standard',
'quantity' => 1,
'delivery_instructions' => 'Discord: shoppex'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.shoppex.io/dev/v1/orders"
payload := strings.NewReader("{\n \"email\": \"[email protected]\",\n \"coupon_code\": \"SPRING10\",\n \"gateway\": \"STRIPE\",\n \"title\": \"Starter Pack checkout\",\n \"custom_fields\": {\n \"source\": \"affiliate\",\n \"campaign\": \"spring_launch\"\n },\n \"items\": [\n {\n \"product_id\": \"prod_starter\",\n \"variant_id\": \"var_standard\",\n \"quantity\": 1,\n \"delivery_instructions\": \"Discord: shoppex\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"data": {
"id": "ord_123",
"uniqid": "11111111-1111-4111-8111-111111111111",
"shop_id": "shop_1",
"customer_id": "cus_1",
"affiliate_link_id": "link_1",
"affiliate_customer_id": "cus_aff_1",
"affiliate_code": "creator123",
"affiliate_discount_amount": 3,
"customer_email": "[email protected]",
"currency": "USD",
"status": "PENDING",
"status_details": null,
"payment_status": "PENDING",
"gateway": "STRIPE",
"flow_type": "CHECKOUT",
"provider_reference": null,
"provider_reference_type": null,
"subtotal": 29.99,
"discount": 3,
"discount_display": 3,
"tax": 0,
"tax_percentage": 0,
"total": 26.99,
"total_display": 26.99,
"balance_paid_amount": 0,
"coupon_id": "coupon_spring10",
"subscription_id": null,
"custom_fields": {
"source": "affiliate",
"campaign": "spring_launch"
},
"is_developer_invoice": false,
"developer_title": null,
"checkout_url": "https://checkout.shoppex.io/invoice/11111111-1111-4111-8111-111111111111",
"items": [
{
"product_id": "prod_starter",
"product_title": "Starter Pack",
"product_type": "DIGITAL",
"variant_title": "Standard",
"quantity": 1,
"unit_price": 29.99,
"total": 29.99,
"delivery_instructions": "Discord: shoppex",
"delivery_instructions_label": "Discord username",
"delivered_items": {
"access_url": "https://downloads.example.com/starter-pack"
}
}
],
"created_at": 1711510800,
"updated_at": 1711510860
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"details": [
{
"field": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"details": [
{
"field": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"details": [
{
"field": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"details": [
{
"field": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"details": [
{
"field": "<string>",
"message": "<string>"
}
]
}
}