> 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": ""
        }
    ]
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gestao.plus/api/private-erp/new_order.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
