Contents
On this page
Link Contact to Account - Plugixa CRM
POST /plugixa-crm/v1/contacts/{id}/accounts
Link a contact to an account, with an optional role.
Any user with access to Plugixa CRM. With Plugixa CRM Pro roles, the user’s role must also allow editing this contact.
Request
POST https://your-site.example/wp-json/plugixa-crm/v1/contacts/31/accounts
Path parameters
| Name | Type | Description |
|---|---|---|
id |
integer |
The contact’s id |
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
account_id |
integer |
Yes | An existing account the contact is not linked to yet. |
role |
string |
No | The contact’s role there, free text. |
is_primary |
boolean |
No | Make this the primary account. Defaults to false, except that a contact’s first link is always primary. |
A primary link takes over: the previous primary link loses its flag and the contact’s account_id becomes this account.
{
"account_id": 15,
"role": "Advisor"
}
Responses
201 Created. data is the contact’s full list of account links.
{
"success": true,
"data": [
{
"id": 7,
"account_id": 12,
"contact_id": 31,
"role": "Buyer",
"is_primary": 1,
"is_inactive": 0,
"created_at": "2026-11-12 09:30:00",
"account_name": "Northwind Traders",
"account_type": "customer"
},
{
"id": 9,
"account_id": 15,
"contact_id": 31,
"role": "Advisor",
"is_primary": 0,
"is_inactive": 0,
"created_at": "2026-11-12 10:15:00",
"account_name": "Initech",
"account_type": "partner"
}
]
}
| Field | Type | Meaning |
|---|---|---|
data[].id |
integer |
The link’s id, used to update or remove it |
data[].account_id |
integer |
The account |
data[].role |
string|null |
The contact’s role at that account |
data[].is_primary |
integer |
1 for the primary account. A contact has at most one |
data[].is_inactive |
integer |
1 when the link is marked inactive |
data[].account_name |
string |
The account’s name |
data[].account_type |
string |
The account’s type |
Errors
| Status | Code | When |
|---|---|---|
404 |
plugixa_crm_not_found |
The contact or the account does not exist, or is in the trash. |
409 |
plugixa_crm_duplicate_affiliation |
The contact is already linked to that account. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-crm/v1/contacts/31/accounts" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"account_id":15,"role":"Advisor"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-crm/v1/contacts/31/accounts');
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([
'account_id' => 15,
'role' => 'Advisor',
]),
]);
$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/contacts/31/accounts', {
method: 'POST',
headers: {
'Authorization': auth,
'Content-Type': 'application/json',
},
body: JSON.stringify({ account_id: 15, role: 'Advisor' }),
});
const { data } = await response.json();
Quick Links
Share