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
organizationIdStringOrganization UUID the order belongs to
externalReferenceStringYour system's order ID — must be unique per tpAppId
invoiceNumberStringInvoice number for accounting
typeOrderTypeEnumB2C or B2B
dispatchingTypeOrderDispatchingTypeEnumAUTOMATIC (default) or MANUAL
priorityPriorityEnumLOW, NORMAL (default), or HIGH
stateOrderStateEnumDRAFT (default) or OPENED
inventoryPolicyInventoryPolicyEnumDENY (default), ALLOW, SKIP, or ADJUST
totalFloatOrder total excluding tax
totalTaxInclusiveFloatOrder total including tax
totalShippingFloatShipping cost
currencyStringISO 4217 currency code (e.g. EUR, USD)
issuedAtDateTimeDate the order was issued in your system
deliveryDeliveryInputDelivery address and contact details
lines[OrderLineInput!]Order lines — at least one required
commentStringFree-text comment visible to warehouse operators

DeliveryInput

FieldTypeRequiredDescription
typeDeliveryTypeEnumPERSON (home delivery) or RELAY_POINT
fullnameStringRecipient full name
emailStringRecipient email address
addressStringStreet address line 1
addressComplementStringStreet address line 2 (apartment, suite, etc.)
zipcodeStringPostal / ZIP code
cityStringCity
countryStringISO 3166-1 alpha-2 country code (e.g. FR, US)
phoneStringRecipient phone number

OrderLineInput

FieldTypeRequiredDescription
labelStringHuman-readable product name
skuStringStock-Keeping Unit identifier
quantityIntQuantity ordered (must be > 0)
priceFloatUnit price excluding tax
vatRateFloatVAT rate as a decimal (e.g. 0.2 for 20%)
totalFloatLine total excluding tax
totalTaxInclusiveFloatLine 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