Skip to content

rmaOrderCreate

Creates a new RMA order. By default the order is created in NEW processing status. Pass accept: true to automatically accept the return on creation, skipping the submit and accept steps.

Required scope: create_rma_orders


Mutation

graphql
mutation RmaOrderCreate($input: RmaOrderInput!) {
  rmaOrderCreate(input: $input) {
    id
    returnNumber
    returnReference
    processingStatus
    deliveryStatus
    financialStatus
    fulfillmentStatus
    expectedResolution
    returnSlipUrl
    lines {
      label
      sku
      reference
      quantity
      reason
      productState
    }
    sender {
      fullname
      email
    }
    deliveryContact {
      fullname
      email
    }
  }
}

Input: RmaOrderInput

FieldTypeRequiredDescription
idIDOptional UUID — if omitted, one is auto-generated
locationIdStringFulfillment location UUID where returns will be received
expectedResolutionRmaOrderExpectedResolutionExpected resolution: NONE, VOUCHER, REPLACE, or REFUND
lines[RmaOrderLineInput!]Return lines — at least one required
senderRmaOrderContactInputSender (customer) contact details
deliveryContactRmaOrderContactInputDelivery (warehouse) contact details
externalIdStringExternal system ID for cross-referencing
externalReferenceStringExternal reference string
commentStringFree-text comment about the return
metaJSONAdditional metadata as JSON
autoGenerateFinancialResolutionBooleanAuto-generate financial resolution on completion (default: false)
autoExecuteFinancialResolutionBooleanAuto-execute financial resolution without review (default: false)
retainedAmountForShippingFloatAmount to retain for return shipping costs (default: 0.0)
acceptBooleanAuto-accept the return on creation (default: false)
linkedOrders[RmaOrderLinkedOrderInput]Original orders linked to this return

RmaOrderLineInput

FieldTypeRequiredDescription
labelStringHuman-readable product name
productStateRmaOrderProductStateProduct condition: BRAND_NEW_WITH_LABEL, BRAND_NEW_WITHOUT_LABEL, WORE, DAMAGED, or DEFECTIVE
productVariantIdStringProduct variant UUID from the catalog
stockReferenceIdStringStock reference UUID
referenceStringProduct reference identifier
skuStringStock-Keeping Unit identifier
orderLineNumberStringLine number from the original order
quantityIntQuantity being returned (must be > 0)
reasonRmaOrderReturnReasonReturn reason: WRONG_ITEM, NOT_RECEIVED, SIZE_PROBLEM, COLOR_PROBLEM, DEFECTIVE, DAMAGED_PRODUCT, UNSATISFIED, or ITEMS_NOT_SOLD
orderLineIdStringOriginal order line UUID
orderIdStringOriginal order UUID
metaJSONAdditional line metadata

RmaOrderContactInput

FieldTypeRequiredDescription
fullnameStringFull name of the contact
emailStringEmail 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)
stateStringState or province
phoneStringPhone number
mobileStringMobile phone number
commentsStringAdditional comments
metadataJSONAdditional contact metadata
taxIdStringTax identification number
formStringLegal form (e.g. SARL, SAS)
capitalStringShare capital
companyIdStringCompany identifier (e.g. SIRET)
registrationStringRegistration number (e.g. RCS)

RmaOrderLinkedOrderInput

FieldTypeRequiredDescription
orderIdStringUUID of the original order

Example Variables

json
{
  "input": {
    "locationId": "loc-uuid-001",
    "expectedResolution": "REFUND",
    "externalId": "RET-2024-001",
    "externalReference": "EXT-RET-001",
    "comment": "Customer reports wrong size received",
    "autoGenerateFinancialResolution": true,
    "autoExecuteFinancialResolution": false,
    "retainedAmountForShipping": 4.99,
    "accept": false,
    "lines": [
      {
        "label": "Classic T-Shirt - Small Blue",
        "productState": "BRAND_NEW_WITH_LABEL",
        "reference": "REF-TSHIRT-001",
        "sku": "TSHIRT-S-BLUE",
        "quantity": 1,
        "reason": "SIZE_PROBLEM",
        "orderId": "order-uuid-001",
        "orderLineId": "order-line-uuid-001"
      }
    ],
    "sender": {
      "fullname": "John Doe",
      "email": "john.doe@example.com",
      "address": "123 Main Street",
      "addressComplement": "Apt 4B",
      "zipcode": "75001",
      "city": "Paris",
      "country": "FR",
      "phone": "+33612345678"
    },
    "deliveryContact": {
      "fullname": "Warehouse Central",
      "email": "warehouse@example.com",
      "address": "456 Warehouse Ave",
      "zipcode": "69001",
      "city": "Lyon",
      "country": "FR",
      "phone": "+33698765432"
    },
    "linkedOrders": [
      {
        "orderId": "order-uuid-001"
      }
    ]
  }
}

Example Response

json
{
  "data": {
    "rmaOrderCreate": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "returnNumber": 1001,
      "returnReference": "RMA-2024-1001",
      "processingStatus": "NEW",
      "deliveryStatus": "PENDING",
      "financialStatus": "NONE",
      "fulfillmentStatus": "PENDING",
      "expectedResolution": "REFUND",
      "returnSlipUrl": null,
      "lines": [
        {
          "label": "Classic T-Shirt - Small Blue",
          "sku": "TSHIRT-S-BLUE",
          "reference": "REF-TSHIRT-001",
          "quantity": 1,
          "reason": "SIZE_PROBLEM",
          "productState": "BRAND_NEW_WITH_LABEL"
        }
      ],
      "sender": {
        "fullname": "John Doe",
        "email": "john.doe@example.com"
      },
      "deliveryContact": {
        "fullname": "Warehouse Central",
        "email": "warehouse@example.com"
      }
    }
  }
}

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 RmaOrderCreate($input: RmaOrderInput!) { rmaOrderCreate(input: $input) { id returnNumber returnReference processingStatus expectedResolution lines { label sku quantity reason } } }",
    "variables": {
      "input": {
        "locationId": "loc-uuid-001",
        "expectedResolution": "REFUND",
        "externalId": "RET-2024-001",
        "comment": "Customer reports wrong size received",
        "autoGenerateFinancialResolution": true,
        "retainedAmountForShipping": 4.99,
        "lines": [
          {
            "label": "Classic T-Shirt - Small Blue",
            "productState": "BRAND_NEW_WITH_LABEL",
            "reference": "REF-TSHIRT-001",
            "sku": "TSHIRT-S-BLUE",
            "quantity": 1,
            "reason": "SIZE_PROBLEM",
            "orderId": "order-uuid-001"
          }
        ],
        "sender": {
          "fullname": "John Doe",
          "email": "john.doe@example.com",
          "address": "123 Main Street",
          "zipcode": "75001",
          "city": "Paris",
          "country": "FR",
          "phone": "+33612345678"
        },
        "deliveryContact": {
          "fullname": "Warehouse Central",
          "email": "warehouse@example.com",
          "address": "456 Warehouse Ave",
          "zipcode": "69001",
          "city": "Lyon",
          "country": "FR"
        },
        "linkedOrders": [
          { "orderId": "order-uuid-001" }
        ]
      }
    }
  }'
js
const mutation = `
  mutation RmaOrderCreate($input: RmaOrderInput!) {
    rmaOrderCreate(input: $input) {
      id
      returnNumber
      returnReference
      processingStatus
      expectedResolution
      lines {
        label
        sku
        quantity
        reason
      }
    }
  }
`;

const variables = {
  input: {
    locationId: 'loc-uuid-001',
    expectedResolution: 'REFUND',
    externalId: 'RET-2024-001',
    comment: 'Customer reports wrong size received',
    autoGenerateFinancialResolution: true,
    retainedAmountForShipping: 4.99,
    lines: [
      {
        label: 'Classic T-Shirt - Small Blue',
        productState: 'BRAND_NEW_WITH_LABEL',
        reference: 'REF-TSHIRT-001',
        sku: 'TSHIRT-S-BLUE',
        quantity: 1,
        reason: 'SIZE_PROBLEM',
        orderId: 'order-uuid-001',
      },
    ],
    sender: {
      fullname: 'John Doe',
      email: 'john.doe@example.com',
      address: '123 Main Street',
      zipcode: '75001',
      city: 'Paris',
      country: 'FR',
      phone: '+33612345678',
    },
    deliveryContact: {
      fullname: 'Warehouse Central',
      email: 'warehouse@example.com',
      address: '456 Warehouse Ave',
      zipcode: '69001',
      city: 'Lyon',
      country: 'FR',
    },
    linkedOrders: [
      { orderId: 'order-uuid-001' },
    ],
  },
};

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.rmaOrderCreate);
python
import os
import requests

mutation = """
mutation RmaOrderCreate($input: RmaOrderInput!) {
  rmaOrderCreate(input: $input) {
    id
    returnNumber
    returnReference
    processingStatus
    expectedResolution
    lines {
      label
      sku
      quantity
      reason
    }
  }
}
"""

variables = {
    "input": {
        "locationId": "loc-uuid-001",
        "expectedResolution": "REFUND",
        "externalId": "RET-2024-001",
        "comment": "Customer reports wrong size received",
        "autoGenerateFinancialResolution": True,
        "retainedAmountForShipping": 4.99,
        "lines": [
            {
                "label": "Classic T-Shirt - Small Blue",
                "productState": "BRAND_NEW_WITH_LABEL",
                "reference": "REF-TSHIRT-001",
                "sku": "TSHIRT-S-BLUE",
                "quantity": 1,
                "reason": "SIZE_PROBLEM",
                "orderId": "order-uuid-001",
            }
        ],
        "sender": {
            "fullname": "John Doe",
            "email": "john.doe@example.com",
            "address": "123 Main Street",
            "zipcode": "75001",
            "city": "Paris",
            "country": "FR",
            "phone": "+33612345678",
        },
        "deliveryContact": {
            "fullname": "Warehouse Central",
            "email": "warehouse@example.com",
            "address": "456 Warehouse Ave",
            "zipcode": "69001",
            "city": "Lyon",
            "country": "FR",
        },
        "linkedOrders": [
            {"orderId": "order-uuid-001"}
        ],
    }
}

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['rmaOrderCreate'])
php
<?php
$mutation = <<<'GQL'
mutation RmaOrderCreate($input: RmaOrderInput!) {
  rmaOrderCreate(input: $input) {
    id
    returnNumber
    returnReference
    processingStatus
    expectedResolution
    lines {
      label
      sku
      quantity
      reason
    }
  }
}
GQL;

$variables = [
    'input' => [
        'locationId'                      => 'loc-uuid-001',
        'expectedResolution'              => 'REFUND',
        'externalId'                      => 'RET-2024-001',
        'comment'                         => 'Customer reports wrong size received',
        'autoGenerateFinancialResolution' => true,
        'retainedAmountForShipping'       => 4.99,
        'lines' => [
            [
                'label'        => 'Classic T-Shirt - Small Blue',
                'productState' => 'BRAND_NEW_WITH_LABEL',
                'reference'    => 'REF-TSHIRT-001',
                'sku'          => 'TSHIRT-S-BLUE',
                'quantity'     => 1,
                'reason'       => 'SIZE_PROBLEM',
                'orderId'      => 'order-uuid-001',
            ],
        ],
        'sender' => [
            'fullname' => 'John Doe',
            'email'    => 'john.doe@example.com',
            'address'  => '123 Main Street',
            'zipcode'  => '75001',
            'city'     => 'Paris',
            'country'  => 'FR',
            'phone'    => '+33612345678',
        ],
        'deliveryContact' => [
            'fullname' => 'Warehouse Central',
            'email'    => 'warehouse@example.com',
            'address'  => '456 Warehouse Ave',
            'zipcode'  => '69001',
            'city'     => 'Lyon',
            'country'  => 'FR',
        ],
        'linkedOrders' => [
            ['orderId' => 'order-uuid-001'],
        ],
    ],
];

$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']['rmaOrderCreate']);
go
package main

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

func main() {
	mutation := `
		mutation RmaOrderCreate($input: RmaOrderInput!) {
			rmaOrderCreate(input: $input) {
				id
				returnNumber
				returnReference
				processingStatus
				expectedResolution
				lines {
					label
					sku
					quantity
					reason
				}
			}
		}`

	variables := map[string]any{
		"input": map[string]any{
			"locationId":                      "loc-uuid-001",
			"expectedResolution":              "REFUND",
			"externalId":                      "RET-2024-001",
			"comment":                         "Customer reports wrong size received",
			"autoGenerateFinancialResolution": true,
			"retainedAmountForShipping":       4.99,
			"lines": []map[string]any{
				{
					"label":        "Classic T-Shirt - Small Blue",
					"productState": "BRAND_NEW_WITH_LABEL",
					"reference":    "REF-TSHIRT-001",
					"sku":          "TSHIRT-S-BLUE",
					"quantity":     1,
					"reason":       "SIZE_PROBLEM",
					"orderId":      "order-uuid-001",
				},
			},
			"sender": map[string]any{
				"fullname": "John Doe",
				"email":    "john.doe@example.com",
				"address":  "123 Main Street",
				"zipcode":  "75001",
				"city":     "Paris",
				"country":  "FR",
				"phone":    "+33612345678",
			},
			"deliveryContact": map[string]any{
				"fullname": "Warehouse Central",
				"email":    "warehouse@example.com",
				"address":  "456 Warehouse Ave",
				"zipcode":  "69001",
				"city":     "Lyon",
				"country":  "FR",
			},
			"linkedOrders": []map[string]any{
				{"orderId": "order-uuid-001"},
			},
		},
	}

	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