Skip to content

orderCreate ​

Creates a new order. By default orders are created in DRAFT state. Pass state: OPENED to skip the draft step and immediately submit for fulfillment.

Required scope: create_orders


Mutation ​

graphql
mutation OrderCreate($input: OrderInput!) {
  orderCreate(input: $input) {
    id
    externalReference
    invoiceNumber
    state
    lines {
      id
      sku
      quantity
    }
  }
}

Input: OrderInput ​

FieldTypeRequiredDescription
organizationIdString✅Organization UUID the order belongs to
externalReferenceString❌Your system's order ID — must be unique per tpAppId
invoiceNumberString❌Invoice number for accounting
typeOrderTypeEnum❌B2C or B2B
dispatchingTypeOrderDispatchingTypeEnum❌AUTOMATIC (default) or MANUAL
priorityPriorityEnum❌LOW, NORMAL (default), or HIGH
stateOrderStateEnum❌DRAFT (default) or OPENED
inventoryPolicyInventoryPolicyEnum❌DENY (default), ALLOW, SKIP, or ADJUST
totalFloat❌Order total excluding tax
totalTaxInclusiveFloat❌Order total including tax
totalShippingFloat❌Shipping cost
currencyString❌ISO 4217 currency code (e.g. EUR, USD)
issuedAtDateTime❌Date the order was issued in your system
deliveryDeliveryInput❌Delivery address and contact details
lines[OrderLineInput!]✅Order lines — at least one required
commentString❌Free-text comment visible to warehouse operators

DeliveryInput ​

FieldTypeRequiredDescription
typeDeliveryTypeEnum❌PERSON (home delivery) or RELAY_POINT
fullnameString❌Recipient full name
emailString❌Recipient email address
addressString❌Street address line 1
addressComplementString❌Street address line 2 (apartment, suite, etc.)
zipcodeString❌Postal / ZIP code
cityString❌City
countryString❌ISO 3166-1 alpha-2 country code (e.g. FR, US)
phoneString❌Recipient phone number

OrderLineInput ​

FieldTypeRequiredDescription
labelString❌Human-readable product name
skuString✅Stock-Keeping Unit identifier
quantityInt✅Quantity ordered (must be > 0)
priceFloat❌Unit price excluding tax
vatRateFloat❌VAT rate as a decimal (e.g. 0.2 for 20%)
totalFloat❌Line total excluding tax
totalTaxInclusiveFloat❌Line total including tax

Example Variables ​

json
{
  "input": {
    "organizationId": "org_123",
    "externalReference": "EXT-2024-001",
    "invoiceNumber": "INV-2024-001",
    "type": "B2C",
    "dispatchingType": "AUTOMATIC",
    "priority": "NORMAL",
    "state": "DRAFT",
    "inventoryPolicy": "DENY",
    "total": 59.98,
    "totalTaxInclusive": 71.98,
    "totalShipping": 5.99,
    "currency": "EUR",
    "issuedAt": "2024-01-15T10:30:00Z",
    "delivery": {
      "type": "PERSON",
      "fullname": "John Doe",
      "email": "john.doe@example.com",
      "address": "123 Main Street",
      "addressComplement": "Apt 4B",
      "zipcode": "75001",
      "city": "Paris",
      "country": "FR",
      "phone": "+33612345678"
    },
    "lines": [
      {
        "label": "Classic T-Shirt - Small Blue",
        "sku": "TSHIRT-S-BLUE",
        "quantity": 2,
        "price": 29.99,
        "vatRate": 0.2,
        "total": 59.98,
        "totalTaxInclusive": 71.98
      }
    ],
    "comment": "Please leave at door if not home"
  }
}

Example Response ​

json
{
  "data": {
    "orderCreate": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "externalReference": "EXT-2024-001",
      "invoiceNumber": "INV-2024-001",
      "state": "DRAFT",
      "lines": [
        {
          "id": "line-uuid-001",
          "sku": "TSHIRT-S-BLUE",
          "quantity": 2
        }
      ]
    }
  }
}

Code Examples ​

bash
curl -X POST https://api-v3.happycolis.com/graphql \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
    "query": "mutation OrderCreate($input: OrderInput!) { orderCreate(input: $input) { id externalReference state lines { id sku quantity } } }",
    "variables": {
      "input": {
        "organizationId": "org_123",
        "externalReference": "EXT-2024-001",
        "invoiceNumber": "INV-2024-001",
        "type": "B2C",
        "dispatchingType": "AUTOMATIC",
        "priority": "NORMAL",
        "state": "DRAFT",
        "inventoryPolicy": "DENY",
        "total": 59.98,
        "totalTaxInclusive": 71.98,
        "totalShipping": 5.99,
        "currency": "EUR",
        "issuedAt": "2024-01-15T10:30:00Z",
        "delivery": {
          "type": "PERSON",
          "fullname": "John Doe",
          "email": "john.doe@example.com",
          "address": "123 Main Street",
          "addressComplement": "Apt 4B",
          "zipcode": "75001",
          "city": "Paris",
          "country": "FR",
          "phone": "+33612345678"
        },
        "lines": [
          {
            "label": "Classic T-Shirt - Small Blue",
            "sku": "TSHIRT-S-BLUE",
            "quantity": 2,
            "price": 29.99,
            "vatRate": 0.2,
            "total": 59.98,
            "totalTaxInclusive": 71.98
          }
        ],
        "comment": "Please leave at door if not home"
      }
    }
  }'
js
const mutation = `
  mutation OrderCreate($input: OrderInput!) {
    orderCreate(input: $input) {
      id
      externalReference
      state
      lines {
        id
        sku
        quantity
      }
    }
  }
`;

const variables = {
  input: {
    organizationId: 'org_123',
    externalReference: 'EXT-2024-001',
    invoiceNumber: 'INV-2024-001',
    type: 'B2C',
    dispatchingType: 'AUTOMATIC',
    priority: 'NORMAL',
    state: 'DRAFT',
    inventoryPolicy: 'DENY',
    total: 59.98,
    totalTaxInclusive: 71.98,
    totalShipping: 5.99,
    currency: 'EUR',
    issuedAt: '2024-01-15T10:30:00Z',
    delivery: {
      type: 'PERSON',
      fullname: 'John Doe',
      email: 'john.doe@example.com',
      address: '123 Main Street',
      addressComplement: 'Apt 4B',
      zipcode: '75001',
      city: 'Paris',
      country: 'FR',
      phone: '+33612345678',
    },
    lines: [
      {
        label: 'Classic T-Shirt - Small Blue',
        sku: 'TSHIRT-S-BLUE',
        quantity: 2,
        price: 29.99,
        vatRate: 0.2,
        total: 59.98,
        totalTaxInclusive: 71.98,
      },
    ],
    comment: 'Please leave at door if not home',
  },
};

const response = await fetch('https://api-v3.happycolis.com/graphql', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${process.env.ACCESS_TOKEN}`,
  },
  body: JSON.stringify({ query: mutation, variables }),
});

const { data } = await response.json();
console.log(data.orderCreate);
python
import os
import requests

mutation = """
mutation OrderCreate($input: OrderInput!) {
  orderCreate(input: $input) {
    id
    externalReference
    state
    lines {
      id
      sku
      quantity
    }
  }
}
"""

variables = {
    "input": {
        "organizationId": "org_123",
        "externalReference": "EXT-2024-001",
        "invoiceNumber": "INV-2024-001",
        "type": "B2C",
        "dispatchingType": "AUTOMATIC",
        "priority": "NORMAL",
        "state": "DRAFT",
        "inventoryPolicy": "DENY",
        "total": 59.98,
        "totalTaxInclusive": 71.98,
        "totalShipping": 5.99,
        "currency": "EUR",
        "issuedAt": "2024-01-15T10:30:00Z",
        "delivery": {
            "type": "PERSON",
            "fullname": "John Doe",
            "email": "john.doe@example.com",
            "address": "123 Main Street",
            "addressComplement": "Apt 4B",
            "zipcode": "75001",
            "city": "Paris",
            "country": "FR",
            "phone": "+33612345678",
        },
        "lines": [
            {
                "label": "Classic T-Shirt - Small Blue",
                "sku": "TSHIRT-S-BLUE",
                "quantity": 2,
                "price": 29.99,
                "vatRate": 0.2,
                "total": 59.98,
                "totalTaxInclusive": 71.98,
            }
        ],
        "comment": "Please leave at door if not home",
    }
}

response = requests.post(
    'https://api-v3.happycolis.com/graphql',
    headers={'Authorization': f'Bearer {os.environ["ACCESS_TOKEN"]}'},
    json={'query': mutation, 'variables': variables},
)

data = response.json()['data']
print(data['orderCreate'])
php
<?php
$mutation = <<<'GQL'
mutation OrderCreate($input: OrderInput!) {
  orderCreate(input: $input) {
    id
    externalReference
    state
    lines {
      id
      sku
      quantity
    }
  }
}
GQL;

$variables = [
    'input' => [
        'organizationId'    => 'org_123',
        'externalReference' => 'EXT-2024-001',
        'invoiceNumber'     => 'INV-2024-001',
        'type'              => 'B2C',
        'dispatchingType'   => 'AUTOMATIC',
        'priority'          => 'NORMAL',
        'state'             => 'DRAFT',
        'inventoryPolicy'   => 'DENY',
        'total'             => 59.98,
        'totalTaxInclusive' => 71.98,
        'totalShipping'     => 5.99,
        'currency'          => 'EUR',
        'issuedAt'          => '2024-01-15T10:30:00Z',
        'delivery' => [
            'type'              => 'PERSON',
            'fullname'          => 'John Doe',
            'email'             => 'john.doe@example.com',
            'address'           => '123 Main Street',
            'addressComplement' => 'Apt 4B',
            'zipcode'           => '75001',
            'city'              => 'Paris',
            'country'           => 'FR',
            'phone'             => '+33612345678',
        ],
        'lines' => [
            [
                'label'             => 'Classic T-Shirt - Small Blue',
                'sku'               => 'TSHIRT-S-BLUE',
                'quantity'          => 2,
                'price'             => 29.99,
                'vatRate'           => 0.2,
                'total'             => 59.98,
                'totalTaxInclusive' => 71.98,
            ],
        ],
        'comment' => 'Please leave at door if not home',
    ],
];

$ch = curl_init('https://api-v3.happycolis.com/graphql');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST           => true,
    CURLOPT_POSTFIELDS     => json_encode(['query' => $mutation, 'variables' => $variables]),
    CURLOPT_HTTPHEADER     => [
        'Content-Type: application/json',
        'Authorization: Bearer ' . getenv('ACCESS_TOKEN'),
    ],
]);

$result = json_decode(curl_exec($ch), true);
curl_close($ch);

print_r($result['data']['orderCreate']);
go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
)

func main() {
	mutation := `
		mutation OrderCreate($input: OrderInput!) {
			orderCreate(input: $input) {
				id
				externalReference
				state
				lines {
					id
					sku
					quantity
				}
			}
		}`

	variables := map[string]any{
		"input": map[string]any{
			"organizationId":    "org_123",
			"externalReference": "EXT-2024-001",
			"invoiceNumber":     "INV-2024-001",
			"type":              "B2C",
			"dispatchingType":   "AUTOMATIC",
			"priority":          "NORMAL",
			"state":             "DRAFT",
			"inventoryPolicy":   "DENY",
			"total":             59.98,
			"totalTaxInclusive": 71.98,
			"totalShipping":     5.99,
			"currency":          "EUR",
			"issuedAt":          "2024-01-15T10:30:00Z",
			"delivery": map[string]any{
				"type":              "PERSON",
				"fullname":          "John Doe",
				"email":             "john.doe@example.com",
				"address":           "123 Main Street",
				"addressComplement": "Apt 4B",
				"zipcode":           "75001",
				"city":              "Paris",
				"country":           "FR",
				"phone":             "+33612345678",
			},
			"lines": []map[string]any{
				{
					"label":             "Classic T-Shirt - Small Blue",
					"sku":               "TSHIRT-S-BLUE",
					"quantity":          2,
					"price":             29.99,
					"vatRate":           0.2,
					"total":             59.98,
					"totalTaxInclusive": 71.98,
				},
			},
			"comment": "Please leave at door if not home",
		},
	}

	body, _ := json.Marshal(map[string]any{
		"query":     mutation,
		"variables": variables,
	})

	req, _ := http.NewRequest("POST", "https://api-v3.happycolis.com/graphql", bytes.NewBuffer(body))
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Authorization", "Bearer "+os.Getenv("ACCESS_TOKEN"))

	resp, _ := http.DefaultClient.Do(req)
	defer resp.Body.Close()

	var result map[string]any
	json.NewDecoder(resp.Body).Decode(&result)
	fmt.Println(result["data"])
}

HappyColis API Documentation