Sale Orders
Initiate Publica.la's checkout flow where customers pay directly through the platform. Orders start with pending status and transition to approved after successful payment via integrated payment gateways (Stripe, MercadoPago, etc.).
See Choosing the Right Order Type for guidance on when to use sale orders.
Creating a Sale Order
Endpoint
POST /api/v3/orders
Request Body
{
"type": "sale",
"external_id": "CART-12345",
"return_url": "https://yoursite.com/thank-you",
"unit_price": 29.99,
"currency_id": "USD",
"user": {
"id": "customer-123",
},
"products": [
{
"type": "content",
"external_id": "9781234567890",
"unit_price": 29.99,
"currency_id": "USD"
}
]
}
Required Fields
| Field | Type | Description |
|---|---|---|
type | string | Must be "sale" |
return_url | string | URL to redirect after payment |
unit_price | float | Total order amount |
currency_id | string | ISO 4217 currency code |
user | object | User information |
user.id | string | User external ID (required) |
products | array | Products in the order |
products[].type | string | content or subscription |
products[].external_id | string | Product external ID |
products[].unit_price | float | Individual product price |
products[].currency_id | string | Product currency |
Optional Fields
| Field | Type | Description |
|---|---|---|
external_id | string | Your unique order ID (max 64 chars) |
user.email | string | User email address |
products[].name | string | Product name (required for auto-creation) |
products[].url | string | External URL (required for auto-creation) |
External Content (Auto-Creation)
If you're selling content hosted outside Publica.la, you can create sale orders without pre-registering the product. When a products[].external_id doesn't exist, the system automatically creates a link-type product using the provided name and url.
This is useful when:
- Content is hosted on your own platform
- You want to track sales in Publica.la without uploading the actual content
- You need to maintain order history for external resources
Example: External Content Sale
curl -X POST "https://yourstore.publica.la/api/v3/orders" \
-H "X-User-Token: your-api-token" \
-H "Content-Type: application/json" \
-d '{
"type": "sale",
"return_url": "https://yourstore.com/confirmation",
"unit_price": 19.99,
"currency_id": "USD",
"user": {
"id": "user-123"
},
"products": [
{
"external_id": "EXTERNAL-COURSE-001",
"type": "content",
"name": "Advanced Photography Course",
"url": "https://yourplatform.com/courses/photography",
"unit_price": 19.99,
"currency_id": "USD"
}
]
}'
The product will be created with external_id: "EXTERNAL-COURSE-001" and readers will be redirected to the provided URL.
Request Examples
Basic Sale Order (USD - Stripe)
curl -X POST "https://yourstore.publica.la/api/v3/orders" \
-H "X-User-Token: your-api-token" \
-H "Content-Type: application/json" \
-d '{
"type": "sale",
"external_id": "WEB-ORDER-12345",
"return_url": "https://yourstore.com/order/confirmation",
"unit_price": 29.99,
"currency_id": "USD",
"user": {
"id": "user-ext-789",
"email": "[email protected]"
},
"products": [
{
"external_id": "PREMIUM-EBOOK",
"type": "content",
"unit_price": 29.99,
"currency_id": "USD"
}
]
}'
Sale Order (ARS - MercadoPago)
curl -X POST "https://yourstore.publica.la/api/v3/orders" \
-H "X-User-Token: your-api-token" \
-H "Content-Type: application/json" \
-d '{
"type": "sale",
"external_id": "ARS-ORDER-789",
"return_url": "https://yourstore.com/gracias",
"unit_price": 5000.00,
"currency_id": "ARS",
"user": {
"id": "user-ar-456",
"email": "[email protected]"
},
"products": [
{
"external_id": "LIBRO-DIGITAL",
"type": "content",
"unit_price": 5000.00,
"currency_id": "ARS"
}
]
}'
Sale Order with Subscription
curl -X POST "https://yourstore.publica.la/api/v3/orders" \
-H "X-User-Token: your-api-token" \
-H "Content-Type: application/json" \
-d '{
"type": "sale",
"external_id": "SUB-ORDER-456",
"return_url": "https://yourstore.com/subscription/welcome",
"unit_price": 9.99,
"currency_id": "USD",
"user": {
"id": "user-sub-123",
"email": "[email protected]"
},
"products": [
{
"external_id": "MONTHLY-PREMIUM",
"type": "subscription",
"unit_price": 9.99,
"currency_id": "USD"
}
]
}'
Sale Order with Multiple Products
curl -X POST "https://yourstore.publica.la/api/v3/orders" \
-H "X-User-Token: your-api-token" \
-H "Content-Type: application/json" \
-d '{
"type": "sale",
"external_id": "CART-BUNDLE-001",
"return_url": "https://yourstore.com/checkout/complete",
"unit_price": 49.97,
"currency_id": "USD",
"user": {
"id": "user-cart-123",
"email": "[email protected]"
},
"products": [
{
"external_id": "EBOOK-001",
"type": "content",
"unit_price": 19.99,
"currency_id": "USD"
},
{
"external_id": "EBOOK-002",
"type": "content",
"unit_price": 14.99,
"currency_id": "USD"
},
{
"external_id": "EBOOK-003",
"type": "content",
"unit_price": 14.99,
"currency_id": "USD"
}
]
}'