Affilibee Logo

Order Submission API

Welcome to the Order Submission API documentation. This API allows you to submit orders for processing. Below, you'll find details on how to authenticate, the expected payload structure, and an example request to help you get started.

Authentication

This API uses Bearer Token authentication. To access the endpoints, include the token in the Authorization header of your requests:

Authorization: Bearer <your_token>

Endpoint

POST /api/orders/create

Request Body

The API expects a JSON payload with the following structure:

Root Fields

  • affiliate_slug (string, required): The unique identifier for the affiliate.
  • order_no (string, required): The unique order number.
  • total_shipping_value (float, required): The total value of shipping costs.
  • total_discount_value (float, optional): The total discount applied to the order.
  • currency_code (string, required): The 3-character currency code (e.g., USD, EUR).

Order Rows

Each order contains an array of order_rows with the following fields:

  • product_sku (string, required): The SKU of the product.
  • product_name (string, required): The name of the product.
  • segment_slug (string, required): The identifier for the product segment.
  • price_value (float, required): The price of the product.
  • tax_value (float, optional): The tax applied to the product.
  • quantity (float, required): The quantity of the product.

Customer

The customer object must include:

  • name (string, required): The full name of the customer.
  • email (string, required): The email address of the customer.

Example Requests

curl -X POST https://api.example.com/api/orders \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
  "affiliate_slug": "affiliate123",
  "order_no": "ORDER-001",
  "total_shipping_value": 15.00,
  "total_discount_value": 5.00,
  "currency_code": "USD",
  "order_rows": [
    {
      "product_sku": "SKU123",
      "product_name": "Product Name A",
      "segment_slug": "segment-001",
      "price_value": 100.00,
      "tax_value": 5.00,
      "quantity": 2
    }
  ],
  "customer": {
    "name": "John Doe",
    "email": "john.doe@example.com"
  }
}'
const requestBody = {
  affiliate_slug: "affiliate123",
  order_no: "ORDER-001",
  total_shipping_value: 15.00,
  total_discount_value: 5.00,
  currency_code: "USD",
  order_rows: [
    {
      product_sku: "SKU123",
      product_name: "Product Name A",
      segment_slug: "segment-001",
      price_value: 100.00,
      tax_value: 5.00,
      quantity: 2
    }
  ],
  customer: {
    name: "John Doe",
    email: "john.doe@example.com"
  }
};

fetch("https://api.example.com/api/orders", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Content-Type": "application/json"
  },
  body: JSON.stringify(requestBody)
})
  .then(response => response.json())
  .then(data => console.log("Success:", data))
  .catch(error => console.error("Error:", error));
<?php

require 'vendor/autoload.php';

use GuzzleHttp\Client;

$client = new Client();
$url = 'https://api.example.com/api/orders';
$token = 'YOUR_ACCESS_TOKEN';

$response = $client->post($url, [
    'headers' => [
        'Authorization' => "Bearer $token",
        'Content-Type' => 'application/json',
    ],
    'json' => [
        'affiliate_slug' => 'affiliate123',
        'order_no' => 'ORDER-001',
        'total_shipping_value' => 15.00,
        'total_discount_value' => 5.00,
        'currency_code' => 'USD',
        'order_rows' => [
            [
                'product_sku' => 'SKU123',
                'product_name' => 'Product Name A',
                'segment_slug' => 'segment-001',
                'price_value' => 100.00,
                'tax_value' => 5.00,
                'quantity' => 2,
            ]
        ],
        'customer' => [
            'name' => 'John Doe',
            'email' => 'john.doe@example.com',
        ],
    ],
]);

echo $response->getBody();
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        var client = new HttpClient();
        var url = "https://api.example.com/api/orders";
        var token = "YOUR_ACCESS_TOKEN";

        var requestBody = new
        {
            affiliate_slug = "affiliate123",
            order_no = "ORDER-001",
            total_shipping_value = 15.00,
            total_discount_value = 5.00,
            currency_code = "USD",
            order_rows = new[]
            {
                new {
                    product_sku = "SKU123",
                    product_name = "Product Name A",
                    segment_slug = "segment-001",
                    price_value = 100.00,
                    tax_value = 5.00,
                    quantity = 2
                }
            },
            customer = new {
                name = "John Doe",
                email = "john.doe@example.com"
            }
        };

        var requestJson = System.Text.Json.JsonSerializer.Serialize(requestBody);
        var content = new StringContent(requestJson, Encoding.UTF8, "application/json");

        client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token}");

        var response = await client.PostAsync(url, content);
        var responseString = await response.Content.ReadAsStringAsync();

        Console.WriteLine(responseString);
    }
}

Response

Success Response (201 Created)

{
    "status": "success",
    "message": "Order submitted successfully",
    "order_id": "unique-order-id"
}

Response

Error Response (400 Bad Request)

{
    "status": "error",
    "message": "Validation failed",
    "errors": {
        "affiliate_slug": ["The affiliate_slug field is required."],
        "currency_code": ["The selected currency_code is invalid."]
    }
}

Feel free to reach out to our support team if you have any questions!

Affilibee Logo

We help e-commerce brands grow through simple, effective, and privacy-friendly affiliate programs. Join us as we build a future of seamless affiliate marketing.

© 2024 Affilibee.