> For the complete documentation index, see [llms.txt](https://docs.gestao.plus/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gestao.plus/api/private-erp/new_order.md).

# Criar Pedido

## Criar um novo pedido

<mark style="color:green;">`POST`</mark> `https://api.gestao.plus/order-external`

Nesta rota você pode adicionar um contato ao usuário.

#### Headers

| Name                                        | Type   | Description         |
| ------------------------------------------- | ------ | ------------------- |
| x-api-key<mark style="color:red;">\*</mark> | string | Token de acesso ERP |
| Origin<mark style="color:red;">\*</mark>    | string | URL de origem       |

#### Request Body

| Name                                         | Type   | Description                      |
| -------------------------------------------- | ------ | -------------------------------- |
| code                                         | string | Código de identificação da venda |
| date                                         | string | Data da venda: Y-m-d H:i:s       |
| utmCampaign                                  | string | UTM Campaign                     |
| utmId                                        | string | UTM ID                           |
| utmMedium                                    | string | UTM Medium                       |
| utmSource                                    | string | UTM Source                       |
| user<mark style="color:red;">\*</mark>       | object | Objeto com os dados do cliente   |
| orderItems<mark style="color:red;">\*</mark> | array  | Array de itens                   |

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

```json
{
    "code": "SUCCESS_ORDER_CREATED",
    "data": {
        "publicToken": "OMzMyMQ_MTY4OTYyMjM4MDUEaa1xNjE_7C44FWNkaVR-GJB871Mb2g",
        "orderCode": "CÓDIGO_DA_VENDA",
        "orderId": "ID_DA_VENDA"
    },
    "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
    "title": "Unknown",
    "status": 201,
    "detail": "Order successfully created"
}

```

{% endtab %}

{% tab title="403 " %}

```json
{
    "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
    "title": "Forbidden",
    "status": 403,
    "detail": "Forbidden, invalid key (x-api-key)"
}
```

{% endtab %}
{% endtabs %}

### Exemplo de corpo da requisição:

#### Detalhando "user":

```json
{
    "user": { // Dados do cliente
        "name": "required", // Nome
        "nameLaw": "", // Razão Social
        "email": "required", // E-mail
        "document": "required", // Documento
        "cellphone": "", // Celular
        "phone": "", // Telefone
        "stateRegistration": "", // Inscrição estadual
        "zipCode": "", // CEP
        "address": "", // Endereço
        "number": "", // Número
        "neighborhood": "", // Bairro
        "addressDetail": "", // Complemento
        "city": "", // Cidade
        "state": "" // Estado
    }
```

#### Detalhando "orderItems":

```json
{
    "orderItems": [
        {
            "product": "required", // SKU do produto
            "quantity": "required", // Quantidade
            "price": "", // Valor desse item
            "discount": "" // Desconto nesse item (R$)
        }
    ]
```

### Exemplo completo do corpo da requisição

```json
{
    "code": "",
    "date": "",
    "note": "",
    "user": {
        "name": "",
        "nameLaw": "",
        "email": "",
        "document": "",
        "cellphone": "",
        "phone": "",
        "stateRegistration": "",
        "zipCode": "",
        "address": "",
        "number": "",
        "neighborhood": "",
        "addressDetail": "",
        "city": "",
        "state": ""
    },
    "orderItems": [
        {
            "product": "",
            "quantity": "",
            "price": "",
            "discount": ""
        }
    ]
}
```
