Deals API
Learn how to manage deals in AchieveApex using the REST API.
Overview
The Deals API allows you to manage sales deals within your organization. You can list, retrieve, create, update, and delete deals, as well as manage deal products.
Base Endpoint
/deals
Deal Object
The deal object contains information about a deal in your organization's sales pipeline.
{ "id": 123, "name": "Enterprise Software Solution", "amount": "25000.00", "currency": "USD", "status": "open", "organization_id": 456, "pipeline_id": 789, "pipeline_stage_id": 101, "contact_id": 202, "company_id": 303, "created_by_user_id": 789, "owned_by_user_id": 789, "created_at": "2023-01-01T00:00:00.000Z", "updated_at": "2023-01-01T00:00:00.000Z", "deleted_at": null, "won_date": null, "lost_date": null, "expected_close_date": "2023-03-01T00:00:00.000Z", "pipelineStage": { "id": 101, "name": "Negotiation", "pipeline_id": 789 }, "pipeline": { "id": 789, "name": "Main Sales Pipeline" }, "company": { "id": 303, "name": "Acme Corporation", "organization_id": 456, "created_by_user_id": 789, "owned_by_user_id": 789 }, "contact": { "id": 202, "first_name": "John", "last_name": "Doe", "email": "john.doe@example.com", "phone": "1234567890", "phone_country_code": "+1", "company_id": 303, "avatar_url": "/path/to/avatar.jpg" }, "owner": { "id": 789, "first_name": "Admin", "last_name": "User", "email": "admin@example.com" }, "dealProducts": [ { "id": 501, "quantity": "2", "price": "10000.00", "description": "Enterprise license", "discount_type": "percentage", "discount_amount": null, "discount_percentage": "10", "tax_percentage": "7", "total_amount_with_tax": "19260.00", "total_amount_without_tax": "18000.00", "product_id": 601, "name": "Software License", "sku": "SL-001" } ] }
List Deals
Retrieve a list of deals for your organization with optional filtering and pagination.
GET /deals curl -X GET https://api.achieveapex.com/deals \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "query": { "organization_id": 456, "status": "open", "pipeline_id": 789, "$limit": 25, "$skip": 0, "$sort": { "created_at": -1 }, "fastJoinForDealsList": true } }'
{ "total": 50, "limit": 25, "skip": 0, "data": [ { "id": 123, "name": "Enterprise Software Solution", "amount": "25000.00", "currency": "USD", "status": "open", "organization_id": 456, "pipeline_id": 789, "pipeline_stage_id": 101, "contact_id": 202, "company_id": 303, "created_by_user_id": 789, "owned_by_user_id": 789, "created_at": "2023-01-01T00:00:00.000Z", "updated_at": "2023-01-01T00:00:00.000Z", "pipelineStage": { "id": 101, "name": "Negotiation" }, "company": { "id": 303, "name": "Acme Corporation" }, "contact": { "id": 202, "first_name": "John", "last_name": "Doe", "email": "john.doe@example.com" }, "owner": { "id": 789, "first_name": "Admin", "last_name": "User" } }, // Additional deals... ] }
Query Parameters
Parameter | Type | Description |
---|---|---|
organization_id | Number | ID of the organization to fetch deals for (required) |
status | String | Filter deals by status ('open', 'won', 'lost') |
pipeline_id | Number | Filter deals by pipeline ID |
pipeline_stage_id | Number | Filter deals by pipeline stage ID |
$limit | Number | Number of deals to return (default: 10) |
$skip | Number | Number of deals to skip (for pagination) |
$sort | Object | Sort criteria (e.g., { "created_at": -1 } for newest first) |
fastJoinForDealsList | Boolean | Include associated data like company, contact, pipeline stage, and owner (recommended) |
Get a Deal
Retrieve a single deal by ID.
GET /deals/:id curl -X GET https://api.achieveapex.com/deals/123 \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "query": { "fastJoinForDealsList": true } }'
{ "id": 123, "name": "Enterprise Software Solution", "amount": "25000.00", "currency": "USD", "status": "open", "organization_id": 456, "pipeline_id": 789, "pipeline_stage_id": 101, "contact_id": 202, "company_id": 303, "created_by_user_id": 789, "owned_by_user_id": 789, "created_at": "2023-01-01T00:00:00.000Z", "updated_at": "2023-01-01T00:00:00.000Z", "deleted_at": null, "won_date": null, "lost_date": null, "expected_close_date": "2023-03-01T00:00:00.000Z", "pipelineStage": { "id": 101, "name": "Negotiation", "pipeline_id": 789 }, "pipeline": { "id": 789, "name": "Main Sales Pipeline" }, "company": { "id": 303, "name": "Acme Corporation", "organization_id": 456, "created_by_user_id": 789, "owned_by_user_id": 789 }, "contact": { "id": 202, "first_name": "John", "last_name": "Doe", "email": "john.doe@example.com", "phone": "1234567890", "phone_country_code": "+1", "company_id": 303, "avatar_url": "/path/to/avatar.jpg" }, "owner": { "id": 789, "first_name": "Admin", "last_name": "User", "email": "admin@example.com" }, "dealProducts": [ { "id": 501, "quantity": "2", "price": "10000.00", "description": "Enterprise license", "discount_type": "percentage", "discount_amount": null, "discount_percentage": "10", "tax_percentage": "7", "total_amount_with_tax": "19260.00", "total_amount_without_tax": "18000.00", "product_id": 601, "name": "Software License", "sku": "SL-001" } ] }
Create a Deal
Create a new deal in your organization.
POST /deals curl -X POST https://api.achieveapex.com/deals \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "organization_id": 456, "name": "New Software Implementation", "amount": 15000, "currency": "USD", "status": "open", "pipeline_id": 789, "pipeline_stage_id": 100, "contact_id": 202, "company_id": 303, "owned_by_user_id": 789, "expected_close_date": "2023-04-15T00:00:00.000Z" }'
{ "id": 124, "name": "New Software Implementation", "amount": "15000.00", "currency": "USD", "status": "open", "organization_id": 456, "pipeline_id": 789, "pipeline_stage_id": 100, "contact_id": 202, "company_id": 303, "created_by_user_id": 789, "owned_by_user_id": 789, "created_at": "2023-01-02T00:00:00.000Z", "updated_at": "2023-01-02T00:00:00.000Z", "deleted_at": null, "won_date": null, "lost_date": null, "expected_close_date": "2023-04-15T00:00:00.000Z" }
Request Parameters
Parameter | Type | Required | Description |
---|---|---|---|
organization_id | Number | Yes | ID of the organization to create the deal in |
name | String | Yes | Name of the deal |
amount | Number | Yes | The monetary value of the deal |
currency | String | Yes | The currency code (e.g., "USD", "EUR") |
status | String | Yes | Deal status ('open', 'won', 'lost') |
pipeline_id | Number | Yes | ID of the pipeline this deal belongs to |
pipeline_stage_id | Number | Yes | ID of the pipeline stage this deal is currently in |
contact_id | Number | No | ID of the contact associated with this deal |
company_id | Number | No | ID of the company associated with this deal |
owned_by_user_id | Number | No | ID of the user who owns this deal (defaults to creator) |
expected_close_date | String | No | Expected date of deal closure (ISO 8601 format) |
Update a Deal
Update an existing deal's information.
PATCH /deals/:id curl -X PATCH https://api.achieveapex.com/deals/123 \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Enterprise Software Solution - Extended", "amount": 30000, "owned_by_user_id": 790, "status": "won", "pipeline_stage_id": 102 }'
{ "id": 123, "name": "Enterprise Software Solution - Extended", "amount": "30000.00", "currency": "USD", "status": "won", "organization_id": 456, "pipeline_id": 789, "pipeline_stage_id": 102, "contact_id": 202, "company_id": 303, "created_by_user_id": 789, "owned_by_user_id": 790, "created_at": "2023-01-01T00:00:00.000Z", "updated_at": "2023-01-03T00:00:00.000Z", "deleted_at": null, "won_date": "2023-01-03T00:00:00.000Z", "lost_date": null, "expected_close_date": "2023-03-01T00:00:00.000Z" }
Delete a Deal
Mark a deal as deleted (soft delete).
DELETE /deals/:id curl -X DELETE https://api.achieveapex.com/deals/123 \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -H "Content-Type: application/json"
{ "id": 123, "name": "Enterprise Software Solution - Extended", "amount": "30000.00", "currency": "USD", "status": "won", "organization_id": 456, "pipeline_id": 789, "pipeline_stage_id": 102, "contact_id": 202, "company_id": 303, "created_by_user_id": 789, "owned_by_user_id": 790, "created_at": "2023-01-01T00:00:00.000Z", "updated_at": "2023-01-03T12:00:00.000Z", "deleted_at": "2023-01-03T12:00:00.000Z", "won_date": "2023-01-03T00:00:00.000Z", "lost_date": null, "expected_close_date": "2023-03-01T00:00:00.000Z" }
Deal Products
Manage products associated with a deal.
Deal Product Object
{ "id": 501, "quantity": "2", "price": "10000.00", "description": "Enterprise license", "discount_type": "percentage", "discount_amount": null, "discount_percentage": "10", "tax_percentage": "7", "total_amount_with_tax": "19260.00", "total_amount_without_tax": "18000.00", "product_id": 601, "deal_id": 123, "organization_id": 456, "name": "Software License", "sku": "SL-001", "created_at": "2023-01-01T00:00:00.000Z", "updated_at": "2023-01-01T00:00:00.000Z", "deleted_at": null }
Add a Product to a Deal
POST /deal-products curl -X POST https://api.achieveapex.com/deal-products \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "deal_id": 123, "organization_id": 456, "product_id": 601, "quantity": 2, "price": 10000, "description": "Enterprise license", "discount_type": "percentage", "discount_percentage": 10, "tax_percentage": 7 }'
Update a Deal Product
PATCH /deal-products/:id curl -X PATCH https://api.achieveapex.com/deal-products/501 \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "quantity": 3, "discount_type": "fixed", "discount_amount": 5000, "discount_percentage": null }'
Remove a Product from a Deal
DELETE /deal-products/:id curl -X DELETE https://api.achieveapex.com/deal-products/501 \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -H "Content-Type: application/json"
Error Handling
The Deals API returns standard HTTP status codes and error messages.
{ "name": "NotFound", "message": "No record found for id '999'", "code": 404, "className": "not-found" }
Status Code | Description |
---|---|
400 Bad Request | Invalid parameters or request |
401 Unauthorized | Missing or invalid authentication |
403 Forbidden | Not authorized to access this organization's deals |
404 Not Found | Deal not found |
500 Internal Server Error | Server error |
Related Documentation
For information on managing companies and contacts associated with deals, see the Companies API and Contacts API documentation.
Report an issue with this documentation
Please log in to report issues with our documentation.