createSalesReturn
Requires the permissions sales:credit_note:approve and sales:credit_note:create.
Starts a return request (RMA) for a customer against a sales invoice. The invoice must exist, every product returned must be on it, and the invoice must be no more than 30 days old unless the request is marked as a customer request. This is the invoice-based flow; the order-based flow is createReturn, and a return created in one flow cannot be advanced by the other. The return is approved as it is created, so it needs the credit notes create and approve permissions, and the customer must be one you may see.
Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.
Example:
- GraphQL
- cURL
mutation CreateSalesReturn($input: CreateSalesReturnInput!) {
createSalesReturn(input: $input) {
id
returnNumber
rmaNumber
status
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "mutation CreateSalesReturn($input: CreateSalesReturnInput!) {\n createSalesReturn(input: $input) {\n id\n returnNumber\n rmaNumber\n status\n }\n}",
"variables": {
"input": {
"customerId": "string",
"invoiceId": "string",
"items": [
{
"condition": "string",
"productId": "string",
"quantity": 0,
"variantId": "string"
}
],
"reason": "string",
"refundMethod": "BANK_TRANSFER",
"warehouseId": "string"
}
}
}
EOF
Variables:
{
"input": {
"customerId": "string",
"invoiceId": "string",
"items": [
{
"condition": "string",
"productId": "string",
"quantity": 0,
"variantId": "string"
}
],
"reason": "string",
"refundMethod": "BANK_TRANSFER",
"warehouseId": "string"
}
}
Response:
{
"data": {
"createSalesReturn": {
"id": "string",
"returnNumber": "string",
"rmaNumber": "string",
"status": "string"
}
}
}
Create a sales return refunded as a credit note:
- GraphQL
- cURL
mutation CreateSalesReturn($input: CreateSalesReturnInput!) {
createSalesReturn(input: $input) {
id
returnNumber
status
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "mutation CreateSalesReturn($input: CreateSalesReturnInput!) {\n createSalesReturn(input: $input) {\n id\n returnNumber\n status\n }\n}",
"variables": {
"input": {
"customerId": "CUSTOMER_ID",
"invoiceId": "INVOICE_ID",
"warehouseId": "WAREHOUSE_ID",
"reason": "Item returned",
"refundMethod": "CREDIT_NOTE",
"items": [
{
"productId": "PRODUCT_ID",
"variantId": "VARIANT_ID",
"quantity": 1,
"condition": "GOOD"
}
]
}
}
}
EOF
Variables:
{
"input": {
"customerId": "CUSTOMER_ID",
"invoiceId": "INVOICE_ID",
"warehouseId": "WAREHOUSE_ID",
"reason": "Item returned",
"refundMethod": "CREDIT_NOTE",
"items": [
{
"productId": "PRODUCT_ID",
"variantId": "VARIANT_ID",
"quantity": 1,
"condition": "GOOD"
}
]
}
}
Response:
{
"data": {
"createSalesReturn": {
"id": "RETURN_ID",
"returnNumber": "RETURN_NUMBER",
"status": "PENDING"
}
}
}
createSalesReturn(
input: CreateSalesReturnInput!
): ReturnResponse!
Arguments
createSalesReturn.input ● CreateSalesReturnInput! non-null input
The details of the sales return to create.
Type
ReturnResponse object
A return created through the RMA flow.