(crm.opportunities)
- list - List opportunities
- create - Create opportunity
- get - Get opportunity
- update - Update opportunity
- delete - Delete opportunity
List opportunities
import apideck_unify
from apideck_unify import Apideck
import os
with Apideck(
api_key=os.getenv("APIDECK_API_KEY", ""),
consumer_id="test-consumer",
app_id="dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
) as apideck:
res = apideck.crm.opportunities.list(service_id="salesforce", filter_={
"status": "Completed",
"monetary_amount": 75000,
}, sort={
"by": apideck_unify.OpportunitiesSortBy.CREATED_AT,
"direction": apideck_unify.SortDirection.DESC,
}, pass_through={
"search": "San Francisco",
}, fields="id,updated_at")
while res is not None:
# Handle items
res = res.next()
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
raw |
Optional[bool] | ➖ | Include raw response. Mostly used for debugging purposes | |
service_id |
Optional[str] | ➖ | Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API. | salesforce |
cursor |
OptionalNullable[str] | ➖ | Cursor to start from. You can find cursors for next/previous pages in the meta.cursors property of the response. | |
limit |
Optional[int] | ➖ | Number of results to return. Minimum 1, Maximum 200, Default 20 | |
filter_ |
Optional[models.OpportunitiesFilter] | ➖ | Apply filters | { "status": "Completed", "monetary_amount": 75000 } |
sort |
Optional[models.OpportunitiesSort] | ➖ | Apply sorting | { "by": "created_at", "direction": "desc" } |
pass_through |
Dict[str, Any] | ➖ | Optional unmapped key/values that will be passed through to downstream as query parameters. Ie: ?pass_through[search]=leads becomes ?search=leads | { "search": "San Francisco" } |
fields |
OptionalNullable[str] | ➖ | The 'fields' parameter allows API users to specify the fields they want to include in the API response. If this parameter is not present, the API will return all available fields. If this parameter is present, only the fields specified in the comma-separated string will be included in the response. Nested properties can also be requested by using a dot notation. Example: fields=name,email,addresses.city In the example above, the response will only include the fields "name", "email" and "addresses.city". If any other fields are available, they will be excluded. |
id,updated_at |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.CrmOpportunitiesAllResponse
Error Type | Status Code | Content Type |
---|---|---|
models.BadRequestResponse | 400 | application/json |
models.UnauthorizedResponse | 401 | application/json |
models.PaymentRequiredResponse | 402 | application/json |
models.NotFoundResponse | 404 | application/json |
models.UnprocessableResponse | 422 | application/json |
models.APIError | 4XX, 5XX | */* |
Create opportunity
import apideck_unify
from apideck_unify import Apideck
import dateutil.parser
import os
with Apideck(
api_key=os.getenv("APIDECK_API_KEY", ""),
consumer_id="test-consumer",
app_id="dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
) as apideck:
res = apideck.crm.opportunities.create(title="New Rocket", primary_contact_id="12345", service_id="salesforce", description="Opportunities are created for People and Companies that are interested in buying your products or services. Create Opportunities for People and Companies to move them through one of your Pipelines.", type_="Existing Customer - Upgrade", monetary_amount=75000, currency=apideck_unify.Currency.USD, win_probability=40, close_date=dateutil.parser.parse("2020-10-30").date(), loss_reason_id="12345", loss_reason="No budget", won_reason_id="12345", won_reason="Best pitch", pipeline_id="12345", pipeline_stage_id="12345", source_id="12345", lead_id="12345", lead_source="Website", contact_id="12345", contact_ids=[
"12345",
], company_id="12345", company_name="Copper", owner_id="12345", priority="None", status="Open", status_id="12345", tags=[
"New",
], custom_fields=[
{
"id": "2389328923893298",
"name": "employee_level",
"description": "Employee Level",
},
], stage_last_changed_at=dateutil.parser.isoparse("2020-09-30T07:43:32.000Z"), pass_through=[
{
"service_id": "<id>",
"extend_paths": [
{
"path": "$.nested.property",
"value": {
"TaxClassificationRef": {
"value": "EUC-99990201-V1-00020000",
},
},
},
],
},
])
assert res.create_opportunity_response is not None
# Handle response
print(res.create_opportunity_response)
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
title |
str | ✔️ | The title or name of the opportunity. | New Rocket |
primary_contact_id |
Nullable[str] | ✔️ | The unique identifier of the primary contact associated with the opportunity. | 12345 |
raw |
Optional[bool] | ➖ | Include raw response. Mostly used for debugging purposes | |
service_id |
Optional[str] | ➖ | Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API. | salesforce |
description |
OptionalNullable[str] | ➖ | A description of the opportunity. | Opportunities are created for People and Companies that are interested in buying your products or services. Create Opportunities for People and Companies to move them through one of your Pipelines. |
type |
OptionalNullable[str] | ➖ | The type of the opportunity | Existing Customer - Upgrade |
monetary_amount |
OptionalNullable[float] | ➖ | The monetary value associated with the opportunity | 75000 |
currency |
OptionalNullable[models.Currency] | ➖ | Indicates the associated currency for an amount of money. Values correspond to ISO 4217. | USD |
win_probability |
OptionalNullable[float] | ➖ | The probability of winning the opportunity, expressed as a percentage. | 40 |
close_date |
datetime | ➖ | The actual closing date for the opportunity. If close_date is null, the opportunity is not closed yet. | 2020-10-30 |
loss_reason_id |
OptionalNullable[str] | ➖ | The unique identifier of the reason why the opportunity was lost. | 12345 |
loss_reason |
OptionalNullable[str] | ➖ | The reason why the opportunity was lost. | No budget |
won_reason_id |
OptionalNullable[str] | ➖ | The unique identifier of the reason why the opportunity was won. | 12345 |
won_reason |
OptionalNullable[str] | ➖ | The reason why the opportunity was won. | Best pitch |
pipeline_id |
OptionalNullable[str] | ➖ | The unique identifier of the pipeline associated with the opportunity | 12345 |
pipeline_stage_id |
OptionalNullable[str] | ➖ | The unique identifier of the stage in the pipeline associated with the opportunity. | 12345 |
source_id |
OptionalNullable[str] | ➖ | The unique identifier of the source of the opportunity. | 12345 |
lead_id |
OptionalNullable[str] | ➖ | The unique identifier of the lead associated with the opportunity. | 12345 |
lead_source |
OptionalNullable[str] | ➖ | The source of the lead associated with the opportunity. | Website |
contact_id |
OptionalNullable[str] | ➖ | The unique identifier of the contact associated with the opportunity. | 12345 |
contact_ids |
List[str] | ➖ | An array of unique identifiers of all contacts associated with the opportunity. | |
company_id |
OptionalNullable[str] | ➖ | The unique identifier of the company associated with the opportunity. | 12345 |
company_name |
OptionalNullable[str] | ➖ | The name of the company associated with the opportunity. | Copper |
owner_id |
OptionalNullable[str] | ➖ | The unique identifier of the user who owns the opportunity. | 12345 |
priority |
OptionalNullable[str] | ➖ | The priority level of the opportunity. | None |
status |
OptionalNullable[str] | ➖ | The current status of the opportunity. | Open |
status_id |
OptionalNullable[str] | ➖ | The unique identifier of the current status of the opportunity. | 12345 |
tags |
List[str] | ➖ | N/A | [ "New" ] |
custom_fields |
List[models.CustomField] | ➖ | N/A | |
stage_last_changed_at |
date | ➖ | The date and time when the stage of the opportunity was last changed. | 2020-09-30T07:43:32.000Z |
pass_through |
List[models.PassThroughBody] | ➖ | The pass_through property allows passing service-specific, custom data or structured modifications in request body when creating or updating resources. | |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.CrmOpportunitiesAddResponse
Error Type | Status Code | Content Type |
---|---|---|
models.BadRequestResponse | 400 | application/json |
models.UnauthorizedResponse | 401 | application/json |
models.PaymentRequiredResponse | 402 | application/json |
models.NotFoundResponse | 404 | application/json |
models.UnprocessableResponse | 422 | application/json |
models.APIError | 4XX, 5XX | */* |
Get opportunity
from apideck_unify import Apideck
import os
with Apideck(
api_key=os.getenv("APIDECK_API_KEY", ""),
consumer_id="test-consumer",
app_id="dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
) as apideck:
res = apideck.crm.opportunities.get(id="<id>", service_id="salesforce", fields="id,updated_at")
assert res.get_opportunity_response is not None
# Handle response
print(res.get_opportunity_response)
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
id |
str | ✔️ | ID of the record you are acting upon. | |
service_id |
Optional[str] | ➖ | Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API. | salesforce |
raw |
Optional[bool] | ➖ | Include raw response. Mostly used for debugging purposes | |
fields |
OptionalNullable[str] | ➖ | The 'fields' parameter allows API users to specify the fields they want to include in the API response. If this parameter is not present, the API will return all available fields. If this parameter is present, only the fields specified in the comma-separated string will be included in the response. Nested properties can also be requested by using a dot notation. Example: fields=name,email,addresses.city In the example above, the response will only include the fields "name", "email" and "addresses.city". If any other fields are available, they will be excluded. |
id,updated_at |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.CrmOpportunitiesOneResponse
Error Type | Status Code | Content Type |
---|---|---|
models.BadRequestResponse | 400 | application/json |
models.UnauthorizedResponse | 401 | application/json |
models.PaymentRequiredResponse | 402 | application/json |
models.NotFoundResponse | 404 | application/json |
models.UnprocessableResponse | 422 | application/json |
models.APIError | 4XX, 5XX | */* |
Update opportunity
import apideck_unify
from apideck_unify import Apideck
import dateutil.parser
import os
with Apideck(
api_key=os.getenv("APIDECK_API_KEY", ""),
consumer_id="test-consumer",
app_id="dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
) as apideck:
res = apideck.crm.opportunities.update(id="<id>", title="New Rocket", primary_contact_id="12345", service_id="salesforce", description="Opportunities are created for People and Companies that are interested in buying your products or services. Create Opportunities for People and Companies to move them through one of your Pipelines.", type_="Existing Customer - Upgrade", monetary_amount=75000, currency=apideck_unify.Currency.USD, win_probability=40, close_date=dateutil.parser.parse("2020-10-30").date(), loss_reason_id="12345", loss_reason="No budget", won_reason_id="12345", won_reason="Best pitch", pipeline_id="12345", pipeline_stage_id="12345", source_id="12345", lead_id="12345", lead_source="Website", contact_id="12345", contact_ids=[
"12345",
], company_id="12345", company_name="Copper", owner_id="12345", priority="None", status="Open", status_id="12345", tags=[
"New",
], custom_fields=[
{
"id": "2389328923893298",
"name": "employee_level",
"description": "Employee Level",
},
{
"id": "2389328923893298",
"name": "employee_level",
"description": "Employee Level",
"value": True,
},
{
"id": "2389328923893298",
"name": "employee_level",
"description": "Employee Level",
},
], stage_last_changed_at=dateutil.parser.isoparse("2020-09-30T07:43:32.000Z"), pass_through=[
{
"service_id": "<id>",
"extend_paths": [
{
"path": "$.nested.property",
"value": {
"TaxClassificationRef": {
"value": "EUC-99990201-V1-00020000",
},
},
},
{
"path": "$.nested.property",
"value": {
"TaxClassificationRef": {
"value": "EUC-99990201-V1-00020000",
},
},
},
{
"path": "$.nested.property",
"value": {
"TaxClassificationRef": {
"value": "EUC-99990201-V1-00020000",
},
},
},
],
},
])
assert res.update_opportunity_response is not None
# Handle response
print(res.update_opportunity_response)
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
id |
str | ✔️ | ID of the record you are acting upon. | |
title |
str | ✔️ | The title or name of the opportunity. | New Rocket |
primary_contact_id |
Nullable[str] | ✔️ | The unique identifier of the primary contact associated with the opportunity. | 12345 |
service_id |
Optional[str] | ➖ | Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API. | salesforce |
raw |
Optional[bool] | ➖ | Include raw response. Mostly used for debugging purposes | |
description |
OptionalNullable[str] | ➖ | A description of the opportunity. | Opportunities are created for People and Companies that are interested in buying your products or services. Create Opportunities for People and Companies to move them through one of your Pipelines. |
type |
OptionalNullable[str] | ➖ | The type of the opportunity | Existing Customer - Upgrade |
monetary_amount |
OptionalNullable[float] | ➖ | The monetary value associated with the opportunity | 75000 |
currency |
OptionalNullable[models.Currency] | ➖ | Indicates the associated currency for an amount of money. Values correspond to ISO 4217. | USD |
win_probability |
OptionalNullable[float] | ➖ | The probability of winning the opportunity, expressed as a percentage. | 40 |
close_date |
datetime | ➖ | The actual closing date for the opportunity. If close_date is null, the opportunity is not closed yet. | 2020-10-30 |
loss_reason_id |
OptionalNullable[str] | ➖ | The unique identifier of the reason why the opportunity was lost. | 12345 |
loss_reason |
OptionalNullable[str] | ➖ | The reason why the opportunity was lost. | No budget |
won_reason_id |
OptionalNullable[str] | ➖ | The unique identifier of the reason why the opportunity was won. | 12345 |
won_reason |
OptionalNullable[str] | ➖ | The reason why the opportunity was won. | Best pitch |
pipeline_id |
OptionalNullable[str] | ➖ | The unique identifier of the pipeline associated with the opportunity | 12345 |
pipeline_stage_id |
OptionalNullable[str] | ➖ | The unique identifier of the stage in the pipeline associated with the opportunity. | 12345 |
source_id |
OptionalNullable[str] | ➖ | The unique identifier of the source of the opportunity. | 12345 |
lead_id |
OptionalNullable[str] | ➖ | The unique identifier of the lead associated with the opportunity. | 12345 |
lead_source |
OptionalNullable[str] | ➖ | The source of the lead associated with the opportunity. | Website |
contact_id |
OptionalNullable[str] | ➖ | The unique identifier of the contact associated with the opportunity. | 12345 |
contact_ids |
List[str] | ➖ | An array of unique identifiers of all contacts associated with the opportunity. | |
company_id |
OptionalNullable[str] | ➖ | The unique identifier of the company associated with the opportunity. | 12345 |
company_name |
OptionalNullable[str] | ➖ | The name of the company associated with the opportunity. | Copper |
owner_id |
OptionalNullable[str] | ➖ | The unique identifier of the user who owns the opportunity. | 12345 |
priority |
OptionalNullable[str] | ➖ | The priority level of the opportunity. | None |
status |
OptionalNullable[str] | ➖ | The current status of the opportunity. | Open |
status_id |
OptionalNullable[str] | ➖ | The unique identifier of the current status of the opportunity. | 12345 |
tags |
List[str] | ➖ | N/A | [ "New" ] |
custom_fields |
List[models.CustomField] | ➖ | N/A | |
stage_last_changed_at |
date | ➖ | The date and time when the stage of the opportunity was last changed. | 2020-09-30T07:43:32.000Z |
pass_through |
List[models.PassThroughBody] | ➖ | The pass_through property allows passing service-specific, custom data or structured modifications in request body when creating or updating resources. | |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.CrmOpportunitiesUpdateResponse
Error Type | Status Code | Content Type |
---|---|---|
models.BadRequestResponse | 400 | application/json |
models.UnauthorizedResponse | 401 | application/json |
models.PaymentRequiredResponse | 402 | application/json |
models.NotFoundResponse | 404 | application/json |
models.UnprocessableResponse | 422 | application/json |
models.APIError | 4XX, 5XX | */* |
Delete opportunity
from apideck_unify import Apideck
import os
with Apideck(
api_key=os.getenv("APIDECK_API_KEY", ""),
consumer_id="test-consumer",
app_id="dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
) as apideck:
res = apideck.crm.opportunities.delete(id="<id>", service_id="salesforce")
assert res.delete_opportunity_response is not None
# Handle response
print(res.delete_opportunity_response)
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
id |
str | ✔️ | ID of the record you are acting upon. | |
service_id |
Optional[str] | ➖ | Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API. | salesforce |
raw |
Optional[bool] | ➖ | Include raw response. Mostly used for debugging purposes | |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.CrmOpportunitiesDeleteResponse
Error Type | Status Code | Content Type |
---|---|---|
models.BadRequestResponse | 400 | application/json |
models.UnauthorizedResponse | 401 | application/json |
models.PaymentRequiredResponse | 402 | application/json |
models.NotFoundResponse | 404 | application/json |
models.UnprocessableResponse | 422 | application/json |
models.APIError | 4XX, 5XX | */* |