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.
/v1/odata/Relationship_Organization_CommercialRelationship_CustomerIn 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.
/v1/odata/Relationship_Organization_CommercialRelationship_Customer?$select=Name| OData option | Purpose |
|---|---|
$select | Choose which fields to return |
$filter | Filter records by a condition |
$top | Limit 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.
/v1/odata/Relationship_Organization_Identity?$expand=Relation($select=ID)&$select=NameNote 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. Add $expand to the request to include the Organization entity in the response (we will need it's ID later).
/v1/odata/Relationship_Organization_CommercialRelationship_Customer?$expand=Organization($select=ID)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.
/v1/odata/Relationship_Person_Contact_Standard?$expand=Person($select=ID)Save the Person.ID from the response — you'll need it to link the contact to the customer.
Cleanup — Delete Created Entities
Now that you've successfully created and linked your first entities, let's clean up the test data.
In Tribe CRM, you must delete child records before parent records. Delete the Relationship first, then the underlying Relation.
1. Delete the Contact Person
/v1/odata/Relation_Person({personId})2. Delete the Relation_Organization (deletes both the organization and all its relationships)
/v1/odata/Relation_Organization({organizationId})