Contents
On this page
Create Opportunity - Plugixa CRM
POST /plugixa-crm/v1/opportunities
Create an opportunity in a pipeline stage.
Any user with access to Plugixa CRM. With Plugixa CRM Pro roles, the user’s role must also allow creating opportunities.
Request
POST https://your-site.example/wp-json/plugixa-crm/v1/opportunities
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
name |
string |
Yes | Must not be blank. |
account_id |
integer |
No | The account. Not checked: any id is stored. |
contact_id |
integer |
No | The contact. Not checked. |
lead_id |
integer |
No | The lead it came from. Not checked. |
pipeline_id |
integer |
No | Defaults to the default pipeline. |
stage_id |
integer |
No | Must belong to the pipeline. Defaults to the pipeline’s first stage. |
amount |
number |
No | Negative values become 0. Defaults to 0. |
currency |
string |
No | Three letters, upper-cased for you. Defaults to the site’s currency. |
probability |
integer |
No | 0 to 100. Defaults to the stage’s probability. |
close_date |
string |
No | YYYY-MM-DD. A datetime is cut to its date. Anything else is stored as null. |
source |
string |
No | Free text. |
lost_reason |
string |
No | Free text. |
description |
string |
No | HTML. Tags not allowed in post content are stripped. |
assigned_user_id |
integer |
No | The WordPress user who owns it. 0 or nothing means none. |
status comes from the stage: open, won or lost. On a won or lost stage closed_at is stamped at once. amount_base is amount converted to the site’s currency at the current rate. status, closed_at, amount_base and last_stage_change_at are worked out for you; values sent for them are ignored. Find pipeline and stage ids with List Pipelines.
{
"name": "Northwind Traders: platform licence",
"account_id": 12,
"contact_id": 31,
"stage_id": 3,
"amount": 12000,
"currency": "EUR",
"close_date": "2026-12-15",
"assigned_user_id": 3
}
Responses
201 Created. data is the new opportunity.
{
"success": true,
"data": {
"id": 24,
"name": "Northwind Traders: platform licence",
"account_id": 12,
"contact_id": 31,
"lead_id": null,
"pipeline_id": 1,
"stage_id": 3,
"amount": 12000,
"currency": "EUR",
"amount_base": 13020,
"probability": 50,
"close_date": "2026-12-15",
"status": "open",
"lost_reason": "",
"source": "",
"description": "",
"last_stage_change_at": "2026-11-12 09:30:00",
"closed_at": null,
"assigned_user_id": "3",
"created_by": "1",
"modified_by": "1",
"created_at": "2026-11-12 09:30:00",
"modified_at": "2026-11-12 09:30:00",
"deleted_at": null,
"history": [
{
"id": 31,
"opportunity_id": 24,
"from_stage_id": null,
"to_stage_id": 3,
"from_status": null,
"to_status": "open",
"amount_at_change": 13020,
"seconds_in_from_stage": null,
"changed_by": "1",
"changed_at": "2026-11-12 09:30:00",
"to_stage_name": "Proposal",
"from_stage_name": null
}
],
"stage": {
"id": 3,
"pipeline_id": 1,
"name": "Proposal",
"slug": "proposal",
"type": "open",
"probability": 50,
"color": "#6366f1",
"position": 2,
"created_at": "2026-11-12 09:30:00"
},
"stages": [
{
"id": 1,
"pipeline_id": 1,
"name": "Qualification",
"slug": "qualification",
"type": "open",
"probability": 10,
"color": "#64748b",
"position": 0,
"created_at": "2026-11-12 09:30:00"
},
{
"id": 2,
"pipeline_id": 1,
"name": "Needs Analysis",
"slug": "needs-analysis",
"type": "open",
"probability": 25,
"color": "#0ea5e9",
"position": 1,
"created_at": "2026-11-12 09:30:00"
},
{
"id": 3,
"pipeline_id": 1,
"name": "Proposal",
"slug": "proposal",
"type": "open",
"probability": 50,
"color": "#6366f1",
"position": 2,
"created_at": "2026-11-12 09:30:00"
},
{
"id": 4,
"pipeline_id": 1,
"name": "Negotiation",
"slug": "negotiation",
"type": "open",
"probability": 75,
"color": "#a855f7",
"position": 3,
"created_at": "2026-11-12 09:30:00"
},
{
"id": 5,
"pipeline_id": 1,
"name": "Closed Won",
"slug": "closed-won",
"type": "won",
"probability": 100,
"color": "#16a34a",
"position": 4,
"created_at": "2026-11-12 09:30:00"
},
{
"id": 6,
"pipeline_id": 1,
"name": "Closed Lost",
"slug": "closed-lost",
"type": "lost",
"probability": 0,
"color": "#dc2626",
"position": 5,
"created_at": "2026-11-12 09:30:00"
}
]
}
}
| Field | Type | Meaning |
|---|---|---|
data.id |
integer |
The opportunity’s id |
data.account_id |
integer|null |
The account |
data.contact_id |
integer|null |
The contact |
data.pipeline_id |
integer |
The pipeline |
data.stage_id |
integer |
The current stage |
data.status |
string |
open, won or lost, taken from the stage’s type |
data.amount |
number |
The value in currency |
data.currency |
string |
Three-letter currency code |
data.amount_base |
number |
amount converted to the site’s currency |
data.probability |
integer |
0 to 100 |
data.close_date |
string|null |
Expected close date, YYYY-MM-DD |
data.closed_at |
string|null |
UTC datetime it reached a won or lost stage |
data.last_stage_change_at |
string |
UTC datetime of the last stage move |
data.assigned_user_id |
string|null |
The WordPress user who owns it. A string, unlike the other ids |
data.history |
array |
Every stage move, with from_stage_name, to_stage_name, amount_at_change, changed_at |
data.stage |
object |
The current stage: name, type, probability, position |
data.stages |
array |
Every stage of the opportunity’s pipeline, in order |
Errors
| Status | Code | When |
|---|---|---|
422 |
plugixa_crm_invalid_name |
name is missing or blank. |
422 |
plugixa_crm_no_pipeline |
No pipeline_id was sent and no pipeline exists. |
422 |
plugixa_crm_invalid_stage |
stage_id is not a stage of the pipeline. |
422 |
plugixa_crm_no_stages |
The pipeline has no stages. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-crm/v1/opportunities" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"name":"Northwind Traders: platform licence","account_id":12,"contact_id":31,"stage_id":3,"amount":12000,"currency":"EUR","close_date":"2026-12-15","assigned_user_id":3}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-crm/v1/opportunities');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => 'admin:' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Northwind Traders: platform licence',
'account_id' => 12,
'contact_id' => 31,
'stage_id' => 3,
'amount' => 12000,
'currency' => 'EUR',
'close_date' => '2026-12-15',
'assigned_user_id' => 3,
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const auth = 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`);
const response = await fetch('https://your-site.example/wp-json/plugixa-crm/v1/opportunities', {
method: 'POST',
headers: {
'Authorization': auth,
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Northwind Traders: platform licence',
account_id: 12,
contact_id: 31,
stage_id: 3,
amount: 12000,
currency: 'EUR',
close_date: '2026-12-15',
assigned_user_id: 3,
}),
});
const { data } = await response.json();
Quick Links
Share