Skip to content

Entities API

Entities are the core building blocks of the Cohera ontology. They represent objects in your pharmaceutical data model such as suppliers, components, products, and certificates.

Every entity has the following structure:

{
"id": "ent_abc123def456",
"type": "supplier",
"name": "Acme Chemicals GmbH",
"attributes": {
"country": "DE",
"qualification_status": "qualified",
"primary_contact": "supplier@acme-chemicals.de",
"risk_level": "low"
},
"relationships": [
{
"type": "supplies",
"target_id": "ent_component_789",
"attributes": {
"primary_supplier": true
}
}
],
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T14:45:00Z",
"created_by": "user_xyz789",
"version": 3
}
TypeDescription
supplierMaterial or service suppliers
componentRaw materials, excipients, packaging
productFinished pharmaceutical products
certificateCoA, CoC, GMP certificates
equipmentManufacturing equipment
facilityManufacturing sites
documentControlled documents

Retrieve a paginated list of entities.

GET /v1/entities
ParameterTypeDescription
typestringFilter by entity type
namestringFilter by name (partial match)
attributes.*stringFilter by attribute value
created_afterdatetimeFilter by creation date
created_beforedatetimeFilter by creation date
updated_afterdatetimeFilter by update date
pageintegerPage number (default: 1)
per_pageintegerItems per page (default: 25, max: 100)
sortstringSort field (prefix with - for descending)
Terminal window
curl -X GET "https://api.cohera.io/v1/entities?type=supplier&attributes.country=DE&per_page=10" \
-H "Authorization: Bearer YOUR_API_KEY"
{
"data": [
{
"id": "ent_abc123",
"type": "supplier",
"name": "Acme Chemicals GmbH",
"attributes": {
"country": "DE",
"qualification_status": "qualified"
},
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
],
"meta": {
"total": 45,
"page": 1,
"per_page": 10,
"total_pages": 5
}
}

Retrieve a single entity by ID.

GET /v1/entities/{entity_id}
ParameterTypeDescription
entity_idstringThe entity ID
ParameterTypeDescription
includestringComma-separated list of relationships to include
Terminal window
curl -X GET "https://api.cohera.io/v1/entities/ent_abc123?include=relationships" \
-H "Authorization: Bearer YOUR_API_KEY"
{
"data": {
"id": "ent_abc123",
"type": "supplier",
"name": "Acme Chemicals GmbH",
"attributes": {
"country": "DE",
"qualification_status": "qualified",
"primary_contact": "supplier@acme-chemicals.de"
},
"relationships": [
{
"type": "supplies",
"target_id": "ent_component_789",
"target_name": "Magnesium Stearate",
"attributes": {
"primary_supplier": true
}
}
],
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T14:45:00Z",
"created_by": "user_xyz789",
"version": 3
}
}

Create a new entity.

POST /v1/entities
FieldTypeRequiredDescription
typestringYesEntity type
namestringYesDisplay name
attributesobjectNoType-specific attributes
relationshipsarrayNoInitial relationships
Terminal window
curl -X POST "https://api.cohera.io/v1/entities" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: create-supplier-$(date +%s)" \
-d '{
"type": "supplier",
"name": "PharmaChem Industries",
"attributes": {
"country": "US",
"qualification_status": "pending",
"primary_contact": "quality@pharmachem.com",
"risk_level": "medium",
"supplier_code": "SUP-2024-001"
}
}'
{
"data": {
"id": "ent_def456ghi789",
"type": "supplier",
"name": "PharmaChem Industries",
"attributes": {
"country": "US",
"qualification_status": "pending",
"primary_contact": "quality@pharmachem.com",
"risk_level": "medium",
"supplier_code": "SUP-2024-001"
},
"relationships": [],
"created_at": "2024-01-20T09:15:00Z",
"updated_at": "2024-01-20T09:15:00Z",
"created_by": "user_abc123",
"version": 1
}
}

Update an existing entity. Supports partial updates.

PATCH /v1/entities/{entity_id}
ParameterTypeDescription
entity_idstringThe entity ID

Include only the fields you want to update:

FieldTypeDescription
namestringDisplay name
attributesobjectAttributes to update (merged with existing)
Terminal window
curl -X PATCH "https://api.cohera.io/v1/entities/ent_abc123" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"attributes": {
"qualification_status": "qualified",
"qualification_date": "2024-01-20",
"risk_level": "low"
}
}'
{
"data": {
"id": "ent_abc123",
"type": "supplier",
"name": "Acme Chemicals GmbH",
"attributes": {
"country": "DE",
"qualification_status": "qualified",
"qualification_date": "2024-01-20",
"primary_contact": "supplier@acme-chemicals.de",
"risk_level": "low"
},
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-20T11:30:00Z",
"created_by": "user_xyz789",
"version": 4
}
}

Delete an entity. This is a soft delete by default.

DELETE /v1/entities/{entity_id}
ParameterTypeDescription
entity_idstringThe entity ID
ParameterTypeDescription
hardbooleanPermanently delete (default: false)
Terminal window
curl -X DELETE "https://api.cohera.io/v1/entities/ent_abc123" \
-H "Authorization: Bearer YOUR_API_KEY"

Returns 204 No Content on success.

POST /v1/entities/{entity_id}/relationships
FieldTypeRequiredDescription
typestringYesRelationship type
target_idstringYesTarget entity ID
attributesobjectNoRelationship attributes
Terminal window
curl -X POST "https://api.cohera.io/v1/entities/ent_supplier_123/relationships" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "supplies",
"target_id": "ent_component_456",
"attributes": {
"primary_supplier": true,
"lead_time_days": 14
}
}'
DELETE /v1/entities/{entity_id}/relationships/{relationship_id}

Retrieve the version history of an entity.

GET /v1/entities/{entity_id}/history
{
"data": [
{
"version": 3,
"changes": {
"attributes.qualification_status": {
"from": "pending",
"to": "qualified"
}
},
"changed_at": "2024-01-20T11:30:00Z",
"changed_by": "user_abc123"
},
{
"version": 2,
"changes": {
"attributes.risk_level": {
"from": "high",
"to": "medium"
}
},
"changed_at": "2024-01-18T09:00:00Z",
"changed_by": "user_def456"
}
]
}

Create multiple entities in a single request.

POST /v1/entities/bulk
{
"entities": [
{"type": "supplier", "name": "Supplier A", "attributes": {...}},
{"type": "supplier", "name": "Supplier B", "attributes": {...}}
]
}

Update multiple entities.

PATCH /v1/entities/bulk
{
"updates": [
{"id": "ent_abc123", "attributes": {"risk_level": "low"}},
{"id": "ent_def456", "attributes": {"risk_level": "medium"}}
]
}