> For the complete documentation index, see [llms.txt](https://docs.sprinthub.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sprinthub.com/topicos/api/api-chamada-api-para-criar-atualizar-oportunidade-no-crm.md).

# API - Chamada API para criar/atualizar Oportunidade no CRM

## Criar Nova Oportunidade

<mark style="color:green;">`POST`</mark> `/crmopportunity?id=XX&i=instancia`

`id = ID do Funil`

`i = nome_da_instancia (exemplo: suaempresa)`

Chamada completa: <https://sprinthub-api-master.sprinthub.app/crmopportunity?id=xx&i=instancia>

\<Criar uma Nova Oportunidade>

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |
| apitoken      | XXXXXXXXX          |

**Body**

<table><thead><tr><th width="313">Name</th><th width="122">Type</th><th>Description</th></tr></thead><tbody><tr><td>title</td><td>string</td><td>Título da Oportnidade</td></tr><tr><td>value</td><td>number</td><td>Valor da Oportunidade (somente n.)</td></tr><tr><td>crm_column</td><td>number</td><td>ID da Coluna</td></tr><tr><td>lead_id</td><td>number</td><td>ID do Lead</td></tr><tr><td>sequence</td><td>number</td><td>ID da Sequência</td></tr><tr><td>status</td><td>string</td><td>open/gain/lost</td></tr><tr><td>expectedCloseDate</td><td>date</td><td>Formato ISO: 2024-03-21T21:27:00.000Z</td></tr><tr><td>user</td><td>number</td><td>ID do usuário responsável</td></tr><tr><td><p>"fields": { </p><p>              "Campo1": "Valor1",</p><p>              "Campo2": "Valor2",</p><p>              "Campo3": "Valor3"</p><p>}</p></td><td>objeto json</td><td>Os campos customizados de CRM precisam estar dentro de um Objeto Json com o nome "fields"</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="Codigos ao lado" %}

{% endtab %}

{% tab title="200" %}

````json
```json
{
    "id": 4534,
    "title": "Test Titulo",
    "value": 1,
    "crm_column": 159,
    "lead_id": 8473,
    "sequence": 3,
    "status": "open",
    "loss_reason": null,
    "gain_reason": null,
    "expectedCloseDate": null,
    "sale_channel": null,
    "campaign": null,
    "user": 156,
    "last_column_change": null,
    "last_status_change": null,
    "gain_date": null,
    "lost_date": null,
    "reopen_date": null,
    "await_column_approved": null,
    "await_column_approved_user": null,
    "reject_appro": null,
    "reject_appro_desc": null,
    "createDate": "2024-03-19T21:14:35.000Z",
    "updateDate": "2024-03-19T21:14:35.000Z",
    "sprint_permission": "all",
    "sprint_permission_user": null,
    "sprint_permission_department": null,
    "sprint_permission_users": [],
    "sprint_permission_users_select": [],
    "sprint_permission_departments": [],
    "sprint_permission_departments_select": [],
    "dataLead": {
        "_id": "645bab79d618593673238ccb",
        "id": 8473,
        "address": null,
        "canal_de_aquisicao": null,
        "channelRestrictions": {
            "instagram": {
                "mainChannel": false,
                "disabled": false,
                "frequencyValue": null,
                "frequencyUnits": "DAY"
            },
            "whatsapp": {
                "mainChannel": false,
                "disabled": false,
                "frequencyValue": null,
                "frequencyUnits": "DAY"
            },
            "email": {
                "mainChannel": true,
                "disabled": false,
                "frequencyValue": 5,
                "frequencyUnits": "DAY"
            },
            "messenger": {
                "mainChannel": false,
                "disabled": false,
                "frequencyValue": null,
                "frequencyUnits": "DAY"
            }
        },
        "city": "São Paulo",
        "company": 2582,
        "country": "Brazil",
        "createDate": "2023-05-10T14:34:33.187Z",
        "createdBy": null,
        "createdByName": "System",
        "email": "teste@teste.com",
        "firstname": "Teste",
        "instancedomain": "teste",
        "ips": [
            "187.34.47.xx",
            "177.76.52.xx",
            "189.0.84.xx",
            "179.193.100.xx",
            "177.62.4.xx",
            "187.89.87.xx"
        ],
        "lastActive": "2024-03-19T21:14:35.693Z",
        "lastname": "Silva",
        "link_instancia": null,
        "mobile": null,
        "owner": null,
        "phone": null,
        "photoUrl": null,
        "points": 30,
        "preferred_locale": "pt-BR",
        "senha_inicial": "teste123",
        "stage": null,
        "state": null,
        "timezone": "America/Sao_Paulo",
        "updatedBy": null,
        "updatedByName": null,
        "updatedDate": null,
        "utmTags": [],
        "whatsapp": "+5511xxxxxxx",
        "zipcode": null,
        "cargo": null,
        "departamento": null,
        "departmentAccess": [],
        "ignoreSubDepartments": false,
        "instance_active": "false",
        "lead_online": "false",
        "partner_instance": null,
        "userAccess": [],
        "createdByType": null
    },
    "dataCompany": {
        "_id": "645bab8axxxxd618565",
        "id": 2582,
        "cnpj": null,
        "companyaddress": null,
        "companyannualrevenue": null,
        "companycity": null,
        "companycountry": null,
        "companyemail": null,
        "companyindustry": null,
        "companyname": "Microsoft Inc",
        "companynemployees": null,
        "companyphone": null,
        "companystate": null,
        "companyzipcode": null,
        "createDate": "2023-05-10T14:34:50.537Z",
        "createdBy": null,
        "createdByName": "System",
        "dores": null,
        "owner": null,
        "photoUrl": null,
        "points": 0,
        "qtdeclientes": null,
        "updatedBy": null,
        "updatedByName": null,
        "updatedDate": null
    },
    "dataCompanyExtra": [
        {
            "id": 2582,
            "cnpj": null,
            "companyaddress": null,
            "companyannualrevenue": null,
            "companycity": null,
            "companycountry": null,
            "companyemail": null,
            "companyindustry": null,
            "companyname": "Microsoft Inc",
            "companynemployees": null,
            "companyphone": null,
            "companystate": null,
            "companyzipcode": null,
            "createDate": "2023-05-10T14:34:50.537Z",
            "createdBy": null,
            "createdByName": "System",
            "dores": null,
            "owner": null,
            "photoUrl": null,
            "points": 0,
            "qtdeclientes": null,
            "updatedBy": null,
            "updatedByName": null,
            "updatedDate": null
        }
    ],
    "fields": {
        "Campo com Espaço": "9969887dddXXXXX"
    },
    "files": [],
    "filesData": []
}
```
````

{% endtab %}

{% tab title="400" %}

````json
```json
{
    "msg": "Mensagem de Erro."
}
```
````

{% endtab %}
{% endtabs %}

***

## Atualizar uma Oportunidade

<mark style="color:green;">`PUT`</mark> `/crmopportunity/XXX?id=XX&i=instancia`

`XXX = ID da Oportunidade (number)`

`id = ID do Funil`

`i = nome_da_instancia (exemplo: suaempresa)`

Chamada completa: <https://sprinthub-api-master.sprinthub.app/crmopportunity/XXX?id=xx&i=instancia>

\<Atualizar uma  Oportunidade>

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |
| apitoken      | XXXXXXXXX          |

**Body**

<table><thead><tr><th width="313">Name</th><th width="122">Type</th><th>Description</th></tr></thead><tbody><tr><td>title</td><td>string</td><td>Título da Oportnidade</td></tr><tr><td>value</td><td>number</td><td>Valor da Oportunidade (somente n.)</td></tr><tr><td>crm_column</td><td>number</td><td>ID da Coluna</td></tr><tr><td>lead_id</td><td>number</td><td>ID do Lead</td></tr><tr><td>sequence</td><td>number</td><td>ID da Sequência</td></tr><tr><td>status</td><td>string</td><td>open/gain/lost</td></tr><tr><td>expectedCloseDate</td><td>date</td><td>Formato ISO: 2024-03-21T21:27:00.000Z</td></tr><tr><td>user</td><td>number</td><td>ID do usuário responsável</td></tr><tr><td><p>"fields": { </p><p>              "Campo1": "Valor1",</p><p>              "Campo2": "Valor2",</p><p>              "Campo3": "Valor3"</p><p>}</p></td><td>objeto json</td><td>Os campos customizados de CRM precisam estar dentro de um Objeto Json com o nome "fields"</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

**Response**

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

````json
```json
{
    "msg": "A oportunidade foi atualizada.",
    "data": {
        "id": XXX,
        "outros campos": ....
}
```
````

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

## Exemplos usando Postman

### Criar Oportunidade

<figure><img src="/files/oDmWxVbovsg13YMk52PH" alt=""><figcaption></figcaption></figure>

###

###

### Atualizar uma Oportunidade existente:

<figure><img src="/files/ZUEXPlxcfbBu7l19jOFU" alt=""><figcaption></figcaption></figure>


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.sprinthub.com/topicos/api/api-chamada-api-para-criar-atualizar-oportunidade-no-crm.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
