# Documentation

Cottoncast offers to you several integrations with well-known and tested  e-commerce platforms. With Cottoncast it is easy to create a fashion brand and get your products out there. We take care of fulfillment.


# Getting started

Our custom API can be used by any platform. It's easy enough to get started. Grab some credentials by creating a custom api channel in your account.

#### Production

{% embed url="<https://api.cottoncast.com>" %}

{% embed url="<https://brands.cottoncast.com>" %}

We use a system of API endpoints, webhooks for near-realtime updates and javascript to create a seamless experience for your customers.


# API Endpoints

Our API is built upon  [REST](http://en.wikipedia.org/wiki/Representational_State_Transfer). It's therefore easy understand and predictable for any developer. Our endpoints accept raw request bodies and return [JSON-encoded](http://www.json.org/) responses. It also uses standard HTTP response codes and authentication.

## Authentication

Our endpoints use basic Authentication. The username is the ID of the sales channel and the password is the secret. Both can be found in your [Studio account](https://brands.cottoncast.com). You can also reset the password in your account.


# Orders

## Retrieve order information

<mark style="color:blue;">`GET`</mark> `/order/$id`

#### Query Parameters

| Name                                 | Type   | Description |
| ------------------------------------ | ------ | ----------- |
| id<mark style="color:red;">\*</mark> | String | Order ID    |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "status": "ok",
    "response": {
        "order": {
            "id": "EA8",
            "store": {
                "name": "My TeSt StOrE",
                "order_id": "000000027"
            },
            "status": {
                "code": "F",
                "label": "Fulfilled",
                "since": "2030-05-11 13:19"
            },
            "addresses": {
                "billing": {
                    "fname": "Chris",
                    "name": "Jansen",
                    "street": "Hoofdstraat",
                    "streetNr": "95",
                    "streetNrExt": "",
                    "postcode": "1234 AB",
                    "city": "Amsterdam",
                    "country": "NL",
                    "email": "chris@email.nl",
                    "phone": "0000000000"
                },
                "shipping": {
                    "fname": "Chris",
                    "name": "Jansen",
                    "street": "Hoofdstraat",
                    "streetNr": "95",
                    "streetNrExt": "",
                    "postcode": "1234 AB",
                    "city": "Amsterdam",
                    "country": "NL",
                    "email": "chris@email.nl",
                    "phone": "0000000000"
                }
            },
            "line_items": [
                {
                    "sku": "RS155M-30-L",
                    "name": "RS155M-30-L",
                    "thumb": "",
                    "image": "",
                    "status": "fulfilled",
                    "options": [
                        {
                            "code": "dtg",
                            "attributes": [
                                {
                                    "name": "src",
                                    "value": "https://test1234.com/mydesign.png",
                                    "source": "user"
                                },
                                {
                                    "name": "preview",
                                    "value": "https://test1234.com/a-preview-of-the-design.png",
                                    "source": "user"
                                },
                                {
                                    "name": "position",
                                    "value": "front",
                                    "source": "user"
                                },
                                {
                                    "name": "qty",
                                    "value": 1,
                                    "source": "default"
                                },
                                {
                                    "name": "offsetX",
                                    "value": -1,
                                    "source": "default"
                                },
                                {
                                    "name": "offsetY",
                                    "value": -1,
                                    "source": "default"
                                },
                                {
                                    "name": "dpi",
                                    "value": 150,
                                    "source": "default"
                                },
                                {
                                    "name": "pallet",
                                    "value": "Standard Pallet",
                                    "source": "default"
                                }
                            ],
                            "status": "fulfilled",
                            "source": "api",
                            "sort_order": 2000
                        }
                    ]
                }
            ],
            "transactions": [
             {
                 "items": [
                     {
                         "ID": 47891,
                         "qty": "1.0000",
                         "sku": "RS155M-30-L",
                         "total": "5.7600"
                     },
                     {
                         "ID": 47892,
                         "qty": "1.0000",
                         "sku": "ISF-EU-T-T",
                         "total": "4.7800"
                     }
                 ],
                 "transaction": {
                     "ID": "21895",
                     "date": "07-12-2030 15:30",
                     "orderRef": "EA8",
                     "total": "10.5400"
                 },
                 "invoice": {
                     "ID": 6389
                 }
             }
             ],
                "shipments": [
                {
                    "status": {
                        "code": "N",
                        "label": "New"
                    },
                    "tracking": {
                        "code": "3SCEBU5051344513",
                        "url": "https://jouw.postnl.nl/track-and-trace/3SCEBU5051344513-NL-1234AB"
                    }
                }
            ]
        }
    }
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

## Create new order

<mark style="color:green;">`POST`</mark> `https://api.cottoncast.com/order`

This endpoint allows you to create a new order.

#### Headers

| Name           | Type   | Description           |
| -------------- | ------ | --------------------- |
| Authentication | string | Basic  Authentication |

#### Request Body

| Name       | Type   | Description                |
| ---------- | ------ | -------------------------- |
| items      | object | Products you want to order |
| shipping   | object | Shipping address           |
| billing    | object | Billing address            |
| order\_ref | string | Your order reference       |
| store      | string | ID of the sales channel    |

{% tabs %}
{% tab title="200 Order received" %}

```javascript
 
{

"store" : "5a2e74fad24826b7836f75c5",

"order_ref" : "100009769",

"billing" : {

    "fname" : "John",

    "name": "Carpenter",

    "street" : "Lange laan",

    "streetNr" : "234",

    "streetNrExt" : "b",

    "postcode" : "1033AZ",

    "city" : "Amsterdam",

    "country" : "NL",

    "phone" : "0612345678",

    "email" : "example@example.com"

  },

 

"shipping" : {

    "fname" : "John",

    "name": "Carpenter",

    "street" : "Lange laan",

    "streetNr" : "234",

    "streetNrExt" : "b",

    "postcode" : "1033AZ",

    "city" : "Amsterdam",

    "country" : "NL",

    "phone" : "0612345678",

    "email" : "example@example.com"

  },

"items": [
    {
      "qty": 1,
      "sku": "RS155M-30-S",
      "options" : [
        {
          "code" : "dtg",
          "attributes" : [
            {
              "name" : "src",
              "value": "https://mydomain.com/design.png"
            },
            {
            "name" : "position",
            "value": "marker: chest; width:80%; top: 1cm"
            },
            {
            "name" : "preview",
            "value": "https://mydomain.com/preview.png"
            }        
          ]
        }
      ]
    },
    {
      "qty": 1,
      "sku": "RS155M-36-L",
      "options" : [
        {
          "code" : "dtg",
          "attributes" : [
            {
              "name" : "src",
              "value": "https://mydomain.com/design2.svg"
            },
            {
            "name" : "position",
            "value": "On the chest, about 80% in width"
            }
          ]
        }
      ]
    },    
    {
      "qty": 1,
      "sku": "7RX-30-L"
    }
  ]
}

```

{% endtab %}

{% tab title="401: Unauthorized " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}


# Products

## Retrieve blank products

<mark style="color:blue;">`GET`</mark> `/products/base`

{% tabs %}
{% tab title="200: OK " %}

```javascript
            {
                "sku": "RS155M",
                "sku_config": "russellcolor-size",
                "name": "Russell Herenshirt",
                "price": 14.5,
                "category": {
                    "code": "T",
                    "label": "T-Shirt"
                },
                "gender": [
                    {
                        "code": "M",
                        "label": "Men"
                    }
                ],
                "tearoffLabel": true,
                "variations": [
                    {
                        "sku": "RS155M-36-S",
                        "name": "Russell Herenshirt Black/S",
                        "sku_config": [
                            {
                                "attribute": "russellcolor",
                                "value": "36",
                                "label": "Black"
                            },
                            {
                                "attribute": "size",
                                "value": "S",
                                "label": "S"
                            }
                        ],
                        "stock": {
                            "code": "S",
                            "label": "In Stock"
                        }
                    },
                    {
                        "sku": "RS155M-36-M",
                        "name": "Russell Herenshirt Black/M",
                        "sku_config": [
                            {
                                "attribute": "russellcolor",
                                "value": "36",
                                "label": "Black"
                            },
                            {
                                "attribute": "size",
                                "value": "M",
                                "label": "M"
                            }
                        ],
                        "stock": {
                            "code": "S",
                            "label": "In Stock"
                        }
                    },
                    {
                        "sku": "RS155M-36-L",
                        "name": "Russell Herenshirt Black/L",
                        "sku_config": [
                            {
                                "attribute": "russellcolor",
                                "value": "36",
                                "label": "Black"
                            },
                            {
                                "attribute": "size",
                                "value": "L",
                                "label": "L"
                            }
                        ],
                        "stock": {
                            "code": "S",
                            "label": "In Stock"
                        }
                    },
                    {
                        "sku": "RS155M-36-XL",
                        "name": "Russell Herenshirt Black/XL",
                        "sku_config": [
                            {
                                "attribute": "russellcolor",
                                "value": "36",
                                "label": "Black"
                            },
                            {
                                "attribute": "size",
                                "value": "XL",
                                "label": "XL"
                            }
                        ],
                        "stock": {
                            "code": "S",
                            "label": "In Stock"
                        }
                    },
                    {
                        "sku": "RS155M-36-2XL",
                        "name": "Russell Herenshirt Black/2XL",
                        "sku_config": [
                            {
                                "attribute": "russellcolor",
                                "value": "36",
                                "label": "Black"
                            },
                            {
                                "attribute": "size",
                                "value": "2XL",
                                "label": "2XL"
                            }
                        ],
                        "stock": {
                            "code": "S",
                            "label": "In Stock"
                        }
                    },
    
                    {
                        "sku": "RS155M-57-S",
                        "name": "Russell Herenshirt Fuchsia/S",
                        "sku_config": [
                            {
                                "attribute": "russellcolor",
                                "value": "57",
                                "label": "Fuchsia"
                            },
                            {
                                "attribute": "size",
                                "value": "S",
                                "label": "S"
                            }
                        ],
                        "stock": {
                            "code": "S",
                            "label": "In Stock"
                        }
                    },
                    {
                        "sku": "RS155M-57-M",
                        "name": "Russell Herenshirt Fuchsia/M",
                        "sku_config": [
                            {
                                "attribute": "russellcolor",
                                "value": "57",
                                "label": "Fuchsia"
                            },
                            {
                                "attribute": "size",
                                "value": "M",
                                "label": "M"
                            }
                        ],
                        "stock": {
                            "code": "S",
                            "label": "In Stock"
                        }
                    },
                    {
                        "sku": "RS155M-57-L",
                        "name": "Russell Herenshirt Fuchsia/L",
                        "sku_config": [
                            {
                                "attribute": "russellcolor",
                                "value": "57",
                                "label": "Fuchsia"
                            },
                            {
                                "attribute": "size",
                                "value": "L",
                                "label": "L"
                            }
                        ],
                        "stock": {
                            "code": "S",
                            "label": "In Stock"
                        }
                    },
                    {
                        "sku": "RS155M-57-XL",
                        "name": "Russell Herenshirt Fuchsia/XL",
                        "sku_config": [
                            {
                                "attribute": "russellcolor",
                                "value": "57",
                                "label": "Fuchsia"
                            },
                            {
                                "attribute": "size",
                                "value": "XL",
                                "label": "XL"
                            }
                        ],
                        "stock": {
                            "code": "S",
                            "label": "In Stock"
                        }
                    },
                    {
                        "sku": "RS155M-57-2XL",
                        "name": "Russell Herenshirt Fuchsia/2XL",
                        "sku_config": [
                            {
                                "attribute": "russellcolor",
                                "value": "57",
                                "label": "Fuchsia"
                            },
                            {
                                "attribute": "size",
                                "value": "2XL",
                                "label": "2XL"
                            }
                        ],
                        "stock": {
                            "code": "S",
                            "label": "In Stock"
                        }
                    }
                ]
            }
            }
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```javascript
{
    "status": "error",
    "message": "Unauthorized"
}
```

{% endtab %}
{% endtabs %}


# Integration

## Get Integrations configuration

<mark style="color:blue;">`GET`</mark> `https://api.cottoncast.com/integrations/config`

This endpoint provides you with all necessary data to write a custom plugin. It mainly provided information about product attributes.\
\
It provides for example more information about product attributes that we use such as categories, agegroups, sizes and colors.

#### Headers

| Name           | Type   | Description                       |
| -------------- | ------ | --------------------------------- |
| Authentication | string | Basic Authentication is required. |

{% tabs %}
{% tab title="200 OK" %}

```javascript
{
    "status": "ok",
    "response": {
        "endpoints": [
            {
                "code": "order",
                "url": "https://api-dev001.cottoncast.com/order/",
                "method": "POST"
            }
        ],
        "webhooks": [
            {
                "code": "orderstatus",
                "url": "https://nerdbynature.nl/cottoncast/orderstatus",
                "method": "POST"
            },
            {
                "code": "product",
                "url": "https://nerdbynature.nl/cottoncast/product",
                "method": "POST"
            }
        ],
        "attributes": [
            {
                "code": "category",
                "type": "category",
                "name": "Category",
                "short_name": "Category",
                "values": [
                    {
                        "code": "T",
                        "label": "T-Shirt",
                        "sort_order": 1
                    },
                    {
                        "code": "H",
                        "label": "Hoodie"
                    },
                    {
                        "code": "S",
                        "label": "Sweater"
                    },
                    {
                        "code": "P",
                        "label": "Polo"
                    },
                    {
                        "code": "B",
                        "label": "Body"
                    }
                ]
            },
            {
                "code": "gender",
                "type": "agegroup",
                "name": "Agegroup",
                "short_name": "Age/Gender",
                "values": [
                    {
                        "code": "M",
                        "label": "Men"
                    },
                    {
                        "code": "W",
                        "label": "Women"
                    },
                    {
                        "code": "B",
                        "label": "Boys"
                    },
                    {
                        "code": "G",
                        "label": "Girls"
                    },
                    {
                        "code": "BB",
                        "label": "Baby Boys"
                    },
                    {
                        "code": "BG",
                        "label": "Baby Girls"
                    }
                ]
            },
            {
                "code": "russellcolor",
                "type": "color",
                "name": "Russell Color",
                "short_name": "Color",
                "values": [
                    {
                        "code": "30",
                        "label": "Weiß",
                        "sort_order": 1
                    },
                    {
                        "code": "36",
                        "label": "Schwarz",
                        "sort_order": 2
                    },
                    {
                        "code": "CG",
                        "label": "Grau",
                        "sort_order": 3
                    },
                    {
                        "code": "CD",
                        "label": "Pink"
                    },
                    {
                        "code": "57",
                        "label": "Fuchsia"
                    },
                    {
                        "code": "41",
                        "label": "Burgundy"
                    },
                    {
                        "code": "CR",
                        "label": "Classic Red"
                    },
                    {
                        "code": "BR",
                        "label": "Bright Red"
                    },
                    {
                        "code": "44",
                        "label": "Orange"
                    },
                    {
                        "code": "K2",
                        "label": "Yellow"
                    },
                    {
                        "code": "LM",
                        "label": "Lime"
                    },
                    {
                        "code": "38",
                        "label": "Bottle Green"
                    },
                    {
                        "code": "AL",
                        "label": "Apple"
                    },
                    {
                        "code": "65",
                        "label": "Turquoise"
                    },
                    {
                        "code": "SC",
                        "label": "Sky"
                    },
                    {
                        "code": "BH",
                        "label": "Bright Royal"
                    },
                    {
                        "code": "FN",
                        "label": "French Navy"
                    },
                    {
                        "code": "LX",
                        "label": "Light Oxford"
                    }
                ]
            },
            {
                "code": "size",
                "type": "size",
                "name": "Clothing size",
                "short_name": "Size",
                "values": [
                    {
                        "code": "S",
                        "label": "S"
                    },
                    {
                        "code": "M",
                        "label": "M"
                    },
                    {
                        "code": "L",
                        "label": "L"
                    },
                    {
                        "code": "XL",
                        "label": "XL"
                    },
                    {
                        "code": "2XL",
                        "label": "2XL"
                    },
                    {
                        "code": "3XL",
                        "label": "3XL"
                    },
                    {
                        "code": "4XL",
                        "label": "4XL"
                    }
                ]
            },
            {
                "code": "bccolor",
                "type": "color",
                "name": "B&C Color",
                "short_name": "Color",
                "values": [
                    {
                        "code": "WHI",
                        "label": "Weiß",
                        "sort_order": 1
                    },
                    {
                        "code": "BLA",
                        "label": "Schwarz",
                        "sort_order": 2
                    },
                    {
                        "code": "LGR",
                        "label": "Grau",
                        "sort_order": 3
                    },
                    {
                        "code": "ATO",
                        "label": "Hellblau"
                    },
                    {
                        "code": "DGR",
                        "label": "Dunkelgrau",
                        "sort_order": 4
                    },
                    {
                        "code": "FUC",
                        "label": "Fuchsia"
                    },
                    {
                        "code": "GOL",
                        "label": "Goldgelb"
                    },
                    {
                        "code": "KHA",
                        "label": "Dunkelgrün"
                    },
                    {
                        "code": "MKH",
                        "label": "Dunkelgrün"
                    },
                    {
                        "code": "MPI",
                        "label": "Millennial rosa"
                    },
                    {
                        "code": "NAV",
                        "label": "Navy blau"
                    },
                    {
                        "code": "ORA",
                        "label": "Orange"
                    },
                    {
                        "code": "RGR",
                        "label": "Hellgrün"
                    },
                    {
                        "code": "RED",
                        "label": "Rot"
                    },
                    {
                        "code": "RBL",
                        "label": "Royal Blau"
                    },
                    {
                        "code": "SGR",
                        "label": "Sport Grau"
                    },
                    {
                        "code": "UOR",
                        "label": "Urban Orange"
                    },
                    {
                        "code": "UPU",
                        "label": "Urban Lila"
                    }
                ]
            },
            {
                "code": "wilkacolor",
                "type": "color",
                "name": "Wilka Color",
                "short_name": "Kleur",
                "values": [
                    {
                        "code": "WHI",
                        "label": "Weiß",
                        "sort_order": 1
                    },
                    {
                        "code": "BLA",
                        "label": "Schwarz",
                        "sort_order": 2
                    },
                    {
                        "code": "ORO",
                        "label": "Rosa"
                    },
                    {
                        "code": "BRO",
                        "label": "Baby Rosa"
                    },
                    {
                        "code": "FUC",
                        "label": "Fuchsia"
                    },
                    {
                        "code": "OGE",
                        "label": "Ocker Gelb"
                    },
                    {
                        "code": "OGR",
                        "label": "Altes grün"
                    },
                    {
                        "code": "ARM",
                        "label": "Army"
                    },
                    {
                        "code": "LIM",
                        "label": "Lime"
                    },
                    {
                        "code": "ORA",
                        "label": "Orange"
                    },
                    {
                        "code": "RED",
                        "label": "Rot"
                    },
                    {
                        "code": "BBL",
                        "label": "Baby Blau"
                    },
                    {
                        "code": "KOB",
                        "label": "Kobalt Blau"
                    },
                    {
                        "code": "AQU",
                        "label": "Wasser Blau"
                    },
                    {
                        "code": "NAV",
                        "label": "Navy blau"
                    }
                ]
            },
            {
                "code": "sizeBabyDouble",
                "type": "size",
                "name": "Clothing size baby's",
                "short_name": "Size",
                "values": [
                    {
                        "code": "50",
                        "label": "50/56"
                    },
                    {
                        "code": "62",
                        "label": "62/68"
                    },
                    {
                        "code": "74",
                        "label": "74/80"
                    },
                    {
                        "code": "86",
                        "label": "86/92"
                    }
                ]
            },
            {
                "code": "sleevetype",
                "type": "general",
                "name": "Sleeve Type",
                "short_name": "Sleeve",
                "values": [
                    {
                        "code": "S",
                        "label": "Kurzarm",
                        "sort_order": 1
                    },
                    {
                        "code": "S",
                        "label": "3/4 Arm",
                        "sort_order": 3
                    },
                    {
                        "code": "L",
                        "label": "Langarm",
                        "sort_order": 2
                    },
                    {
                        "code": "W",
                        "label": "Ohne Arm",
                        "sort_order": 4
                    }
                ]
            },
            {
                "code": "fittype",
                "type": "general",
                "name": "Fit Type",
                "short_name": "Fit",
                "values": [
                    {
                        "code": "L",
                        "label": "Loose fit",
                        "sort_order": 1
                    },
                    {
                        "code": "R",
                        "label": "Regular Fit",
                        "sort_order": 2
                    },
                    {
                        "code": "S",
                        "label": "Slim Fit",
                        "sort_order": 3
                    }
                ]
            }
        ]
    }
}
```

{% endtab %}
{% endtabs %}


# Webhooks

We use several webhooks to update you and your customer near real-time.

## Authentication

Most of the time webhooks are public-facing http endpoints. So how can you be sure that a request comes from Cottoncast? Each request we sent to your webhook is signed based on the request body.

Each request coming from Cottoncast will have a header **Cottoncast-Authentication**. A Hash is calculated based on the body content using the secret in your Cottoncast account.

#### Verifying the origin of Webhook requests

```php
$my_secret = 'CjXttYCtXJyDoyUxed8j'; // You can find this on the saleschannel page in your account.
$header_hmac = $_SERVER['HTTP_COTTONCAST_AUTHENTICATION'];
$body_hmac = hash_hmac('sha256', file_get_contents('php://input'),$my_secret);

if ($header_hmac !== $body_hmac) 
  throw new Exception("Unauthorized");


```

## Response codes

We monitor the requests we make to your webhooks. Returning a useful status code will help us and and yourself to identify problems as quickly as possible.&#x20;

{% hint style="info" %}
A 200 response is considered a successful delivery of the message.
{% endhint %}

| Code | Description         |
| ---- | ------------------- |
| 200  | OK                  |
| 202  | Accepted            |
| 400  | Bad Request         |
| 401  | Unauthorized        |
| 404  | Not found           |
| 405  | Method not found    |
| 503  | Service Unavailable |


# Products

## Product updates

<mark style="color:green;">`POST`</mark> `https://your.store.com/cottoncast/product`

Each time you create or edit a product in PODrocket we will make a request to this webhook. You can configure the URL in your sales channel settings.\ <br>

#### Query Parameters

| Name   | Type    | Description                                                           |
| ------ | ------- | --------------------------------------------------------------------- |
| recipe | string  | The API will do its best to find a cake matching the provided recipe. |
| gluten | boolean | Whether the cake should be gluten-free or not.                        |

{% tabs %}
{% tab title="202 Product successfully received for processing." %}

```javascript
{
    "status": "ok"
}
```

{% endtab %}

{% tab title="404 Could not find a cake matching this query." %}

```javascript
{
    "status": "error",
    "message": "Page not found"
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Your webhook should respond with code 202: Accepted. Processing of the product data must be done asynchronously.
{% endhint %}

### Example request body

```javascript
{
  "name": "BigBrand T-shirt Black",
  "description": "Lorem ipsum",
  "status": {
    "code": "P",
    "description": "Published"
  },
  "sku": "34RX",
  "brand": "BigBrand",
  "category": {
    "code": "S",
    "description": "T-Shirt"
  },
  "agegroups": [
    {
      "code": "M",
      "description": "Men"
    }
  ],
  "price": 29.95,
  "config": {
    "type": "predesign",
    "code": "color-size",
    "labels": [
      {
        "code": "color",
        "label": "Color"
      },
      {
        "code": "size",
        "label": "Size"
      }
    ]
  },
  "variants": [
    {
      "sku": "34RX-BLA-S",
      "hexcolor": "#dedede",
      "status": {
        "code": "A",
        "name": "Active"
      },
      "config": {
        "options": [
          {
            "code": "color",
            "type": "color",
            "value": "BLA",
            "label": "Black"
          },
          {
            "code": "size",
            "type": "size",
            "value": "S",
            "label": "S"
          }
        ]
      },
      "images": [
        {
          "code": "F",
          "description": "Front",
          "url": "https://texo.cottoncast.com/EFG763.png"
        }
      ]
    }
  ],
  "images": [
    {
      "code": "F",
      "description": "Front",
      "url": "https://texo.cottoncast.com/EFG763.png"
    }
  ],
  "tags": [
    "men",
    "hello",
    "world"
  ],
  "meta": {
    "saleschannelID": "5d963a94b9e99e4ce0468ff2",
    "language": "en"
  }
}
```


# Orderstatus

## Get status updates for Cottoncast orders

<mark style="color:green;">`POST`</mark> `https://your.store.com/cottoncast/orderstatus`

This url is an example. You can configure your own URL in your Studio account. Each time an order is updated in our system we will make a request to this webhook. For example when we ship an order.

#### Request Body

| Name             | Type   | Description                                     |
| ---------------- | ------ | ----------------------------------------------- |
| status.timestamp | string | The time the status has changed                 |
| status.code      | string | A status code. The letter "C" means Complete.   |
| status           | object | The status of the order                         |
| orderID          | string | The Cottoncast Order ID                         |
| ref              | string | The order reference you have passed along to us |

{% tabs %}
{% tab title="200 Orderstatus successfully updated." %}

```javascript
{
    "status": "ok"
}
```

{% endtab %}

{% tab title="404 Could not find the order" %}

```javascript
{
    "status": "error",
    "message": "Order 41 not found"
}
```

{% endtab %}
{% endtabs %}

### Example request body

```javascript
{
  "orderID" : "3AF7",
  "ref" : "41",
  "status" : {
    "code" : "C",
    "timestamp" : 1622007287
  },
 "shipments":[
   {
     "carrier":"postnl",
     "carrierName":"Postnl",
     "trackingcode":"3SCEBU123456789",
     "trackingurl":"https:\/\/jouw.postnl.nl\/track-and-trace\/3SCEBU123456789-NL-1000AB",
     "new":true
   }
 ]  
}

```

## Status codes

| Code | Label         | Description                                              |
| ---- | ------------- | -------------------------------------------------------- |
| N    | New           | The shipment has just been created                       |
| L    | Label created | A label has been created and printed for the package(s). |
| R    | Ready         | The shipment is ready for collection by the carrier.     |
| C    | Collected     | The shipment is collected by the carrier                 |
| E    | En route      | The shipment is en-route to the customer.                |
| I    | Problem       | There is a problem with the shipment.                    |
| X    | Lost          | The package has been lost by the carrier.                |
| D    | Delivered     | The package is delivered.                                |


# WooCommerce

## Introduction

WooCommerce is popular e-commerce plugin for Wordpress. As you may know, It has a huge community that you can depend on for plugins and support.

#### Requirements

An integration always has two sides. You need to create a sales channel in your Cottoncast account. And your WooCommerce store needs our plugin.<br>

## Create sales channel

* [ ] Goto our app and [login](https://studio.cottoncast.com/sign/in)
* [ ] Goto **Settings > Sales channels**&#x20;
* [ ] Click **Add a new channel**
* [ ] Enter a **description,** choose a **language** and click **add WooCommerce channel**
* [ ] Enter your shop's **domain**
* [ ] Click **save**<br>

{% hint style="info" %}
Keep the tab open. You will need the Channel ID and Secret in the next step.
{% endhint %}

## Install plugin&#x20;

#### Download

You can download and install the plugin via your WooCommerce store's admin.

[Download plugin](https://plugins.cottoncast.com/cottoncast-woocommerce_latest.zip)

#### Composer

The plugin can also be installed and maintained using composer.

```bash
composer require cottoncast/woocommerce
```

{% hint style="info" %}
Don't forget to activate the plugin.
{% endhint %}

## Configure plugin

You will need the **channel ID** and **secret** from the created sales channel in the previous step.Goto **Settings > Sales channels** in your CottonCast account. Select the sales channel for your store.&#x20;

#### Configure cottoncast plugin

Goto **settings > Cottoncast** in your WooCommerce store.

You will see at least these settings:

| **Setting**     | Description                                       |
| --------------- | ------------------------------------------------- |
| Username        | Should match **channel ID**                       |
| Secret          | Should match **secret**                           |
| Order endpoint  | https\://*api.cottoncast.com*/order               |
| Config endpoint | https\://*api.cottoncast.com*/integrations/config |

That's it. You are done. Your shop and our system are now talking to each other.

## Bugs & Features

The plugin is publicly maintained at [Github](https://github.com/cottoncast/woocommerce). If you have found any bugs or want to request a feature you can do so on [Github](https://github.com/cottoncast/woocommerce).

## Common issues

### Cronjob

Make sure to disable WP\_CRON and use a proper cronjob.

### PHP Limits

Our plugin downloads images and processes them. That takes some time, memory and computing power. Make sure the plugin does not hit any limits.


# Magento

## Introduction

Magento is the most advanced and technical solution. It provides you everything you need. Magento users tend to have specific requirement and most often implement customization solutions. Our custom API is the best suited solution for that.

{% content-ref url="/pages/-LqRPxunlXjbyVH\_MhFW" %}
[Broken mention](broken://pages/-LqRPxunlXjbyVH_MhFW)
{% endcontent-ref %}

##


