Skip to main content

Creating and Linking Contacts and Customers

In this tutorial, you'll learn how to work with two of the most fundamental entities in Tribe CRM: Contacts (People) and Customers (Organizations). You'll create new records and establish relationships between them — just like you would in the Tribe CRM interface, but through the API.


Step 2.1 — Check Existing Customers

Before creating anything, let's see what Customers are already in the system.

Request

GET {{Tribe CRM domain}}/v1/odata/Relationship_Organization_CommercialRelationship_Customer
Authorization: Bearer {{access_token}}
Understanding the data model

In Tribe CRM, a Customer is a Relationship — specifically a Relationship_Organization_CommercialRelationship_Customer. Relationships connect a Relation (the directory entry) to a specific role in your CRM. The same organization can be both a Customer and a Supplier at the same time.


Step 2.2 — Filter Results

The previous response was probably overwhelming. Let's learn how to get exactly what we need using OData query options.

Request

GET {{Tribe CRM domain}}/v1/odata/Relationship_Organization_CommercialRelationship_Customer?$select=Name
Authorization: Bearer {{access_token}}
OData optionPurpose
$selectChoose which fields to return
$filterFilter records by a condition
$topLimit the number of results

Step 2.3 — Find Your Organization (Customer Part I)

When you want to add a new customer to Tribe CRM, you first need to link them to your organization. Every customer relationship references the owning organization's Relation ID.

Request

GET {{Tribe CRM domain}}/v1/odata/Relationship_Organization_Identity?$expand=Relation($select=ID)&$select=Name
Authorization: Bearer {{access_token}}

Note the Relation.ID from the response — you'll need it in the next step.


Step 2.4 — Create a Customer (Customer Part II)

Now let's create a new customer organization. This POST request creates a new Relation_Organization and wraps it in a Customer relationship in one call.

Request

POST {{Tribe CRM domain}}/v1/odata/Relationship_Organization_CommercialRelationship_Customer
Authorization: Bearer {{access_token}}
Content-Type: application/json

Body

{
"Relation": {
"ID": "{{your_organization_relation_id}}"
},
"Organization": {
"Name": "ACME Corp.",
"Website": "www.acmecorp.org",
"NumberOfEmployees": 5
}
}

The response will include the new ID for the Customer relationship. Save it for the cleanup step.


Step 2.5 — Create a Contact

Now let's create a contact person. This request creates a Person entity wrapped in a standard Contact relationship.

Request

POST {{Tribe CRM domain}}/v1/odata/Relationship_Person_Contact_Standard
Authorization: Bearer {{access_token}}
Content-Type: application/json

Body

{
"Person": {
"FirstName": "Wile E.",
"LastName": "Coyote"
}
}

Save the Relation.ID from the response — you'll need it to link the contact to the customer.


Step 2.6 — Find Relation IDs Before Linking

Before you can link the person to the organization, you need the Relation IDs for both — not the relationship IDs.

Relations vs Relationships
  • Relation — the directory entry (the person or organization itself)
  • Relationship — a role assigned to that entry (Customer, Contact, Employee…)

When linking two entities, you always reference their Relation.ID.

Request

GET {{Tribe CRM domain}}/v1/odata/Relation_Organization?$filter=Name eq 'ACME Corp.'
Authorization: Bearer {{access_token}}

Now that you have both relation IDs, connect the person to ACME Corp. as a contact person.

Request

POST {{Tribe CRM domain}}/v1/odata/Relationship_Person_Contact_Standard
Authorization: Bearer {{access_token}}
Content-Type: application/json

Body

{
"Relation": {
"ID": "{{acme_corp_relation_id}}"
},
"Person": {
"ID": "{{wile_e_coyote_person_id}}"
}
}

Cleanup — Delete Created Entities

Now that you've successfully created and linked your first entities, let's clean up the test data.

Parent-child deletion order

In Tribe CRM, you must delete child records before parent records. Delete the Relationship first, then the underlying Relation.

1. Delete the Relation_Organization (deletes both the organization and all its relationships)

DELETE {{Tribe CRM domain}}/v1/odata/Relation_Organization({{acme_corp_relation_id}})
Authorization: Bearer {{access_token}}

2. Delete the Contact Person

DELETE {{Tribe CRM domain}}/v1/odata/Relation_Person({{wile_e_coyote_relation_id}})
Authorization: Bearer {{access_token}}