> 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/en/topics/api/api-api-call-to-create-update-opportunity-in-crm.md).

# API - API call to create/update Opportunity in CRM

## Create New Opportunity

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

`id = Funnel ID`

`i = instance_name (example: yourcompany)`

Full call: [https://sprinthub-api-master.sprinthub.app/crmopportunity?id=xx\&i=instance](https://sprinthub-api-master.sprinthub.app/crmopportunity?id=xx\&i=instancia)

\<Create a New Opportunity>

**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>Opportunity Title</td></tr><tr><td>value</td><td>number</td><td>Opportunity Value (numbers only)</td></tr><tr><td>crm_column</td><td>number</td><td>Column ID</td></tr><tr><td>lead_id</td><td>number</td><td>Lead ID</td></tr><tr><td>sequence</td><td>number</td><td>Sequence ID</td></tr><tr><td>status</td><td>string</td><td>open/gain/lost</td></tr><tr><td>expectedCloseDate</td><td>date</td><td>ISO format: 2024-03-21T21:27:00.000Z</td></tr><tr><td>user</td><td>number</td><td>Responsible user ID</td></tr><tr><td><p>"fields": { </p><p>              "Field1": "Value1",</p><p>              "Field2": "Value2",</p><p>              "Field3": "Value3"</p><p>}</p></td><td>json object</td><td>CRM custom fields need to be inside a JSON object named "fields"</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="Codes on the side" %}

{% endtab %}

{% tab title="200" %}

````json
```json
{
    "id": 4534,
    "title": "Test Title",
    "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,
        "acquisition_channel": 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": "Test",
        "instancedomain": "test",
        "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",
        "initial_password": "teste123",
        "stage": null,
        "state": null,
        "timezone": "America/Sao_Paulo",
        "updatedBy": null,
        "updatedByName": null,
        "updatedDate": null,
        "utmTags": [],
        "whatsapp": "+5511xxxxxxx",
        "zipcode": null,
        "role": null,
        "department": 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",
        "pain_points": null,
        "owner": null,
        "photoUrl": null,
        "points": 0,
        "customer_count": 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",
            "pain_points": null,
            "owner": null,
            "photoUrl": null,
            "points": 0,
            "customer_count": null,
            "updatedBy": null,
            "updatedByName": null,
            "updatedDate": null
        }
    ],
    "fields": {
        "Field with Space": "9969887dddXXXXX"
    },
    "files": [],
    "filesData": []
}
```
````

{% endtab %}

{% tab title="400" %}

````json
```json
{
    "msg": "Error message."
}
```
````

{% endtab %}
{% endtabs %}

***

## Update an Opportunity

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

`XXX = Opportunity ID (number)`

`id = Funnel ID`

`i = instance_name (example: yourcompany)`

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

\<Update an Opportunity>

**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>Opportunity Title</td></tr><tr><td>value</td><td>number</td><td>Opportunity Value (numbers only)</td></tr><tr><td>crm_column</td><td>number</td><td>Column ID</td></tr><tr><td>lead_id</td><td>number</td><td>Lead ID</td></tr><tr><td>sequence</td><td>number</td><td>Sequence ID</td></tr><tr><td>status</td><td>string</td><td>open/gain/lost</td></tr><tr><td>expectedCloseDate</td><td>date</td><td>ISO format: 2024-03-21T21:27:00.000Z</td></tr><tr><td>user</td><td>number</td><td>Responsible user ID</td></tr><tr><td><p>"fields": { </p><p>              "Field1": "Value1",</p><p>              "Field2": "Value2",</p><p>              "Field3": "Value3"</p><p>}</p></td><td>json object</td><td>CRM custom fields need to be inside a JSON object named "fields"</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

**Response**

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

````json
```json
{
    "msg": "The opportunity has been updated.",
    "data": {
        "id": XXX,
        "other fields": ....
}
```
````

{% endtab %}

{% tab title="400" %}

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

{% endtab %}
{% endtabs %}

## Examples using Postman

### Create Opportunity

<figure><img src="https://684109703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FzUKkagBNy5uQ7AtGNa%2Fuploads%2F5feiOCMW26d4vozCXtpk%2FCaptura%20de%20Tela%202024-03-19%20a%CC%80s%2018.41.05.png?alt=media&amp;token=b99a2025-1839-424b-a5d8-f2bcd121f8a9" alt=""><figcaption></figcaption></figure>

###

###

### Update an existing Opportunity:

<figure><img src="https://684109703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FzUKkagBNy5uQ7AtGNa%2Fuploads%2FvsXTUynZe6sxOaY9JhRy%2FCaptura%20de%20Tela%202024-03-19%20a%CC%80s%2018.41.38.png?alt=media&amp;token=763c804e-2aec-49b9-95f4-bf3af6e10bbd" 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/en/topics/api/api-api-call-to-create-update-opportunity-in-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.
