Here we describe the steps for creating a new relationship between two objects in your repository.
HTTP responses
HTTP response status code |
Interpretation |
---|---|
201 Created |
Relationship created successfully |
401 Unauthorized |
Invalid or missing API key secret and/or tenant |
400 Bad Request |
Relationship cannot be created due to one or more parameters being missing or incorrect |
403 Forbidden |
The user is not allowed to create a relationship between the two objects |
Conditions
-
To create a relationship between two objects, you must have 'read and write' permissions on relations for both object types
-
It is only possible to create a relationship between two objects that have an enabled combination for that relationship type
-
It is only possible to create a relationship between two active objects
-
Object IDs and template IDs must exist in the tenant
To create a new relationship, make a POST request to the /relations
endpoint specifying:
-
Resource/endpoint destination URL
-
The header for your API request
-
The request body, which must include:
Parameter |
Required |
Type |
Description |
---|---|---|---|
to_object_id |
✓ |
string |
Unique identifier for the target object |
from_object_id |
✓ |
string |
Unique identifier for the source object |
template_id |
✓ |
string |
Unique identifier for the relationship template |
label |
X |
string |
Relationship label |
Here is an example API request which shows how to create a new relationship of the type Used by
between two objects:
curl -L 'https://public-api.eu.bluedolphin.app/v1/relations' \
-H 'x-api-key: YOURAPIKEYSECRET' \
-H 'tenant: yourtenantname' \
-H 'Content-Type: application/json' \
-d '{
"template_id":"5333e9d68aadd096c838fe93",
"from_object_id": "643e9020d97c6a7e28885255",
"to_object_id":"64369407346524508498d5a2",
"label":"optional relationship label"
}'
A successful call returns a response with a 201 OK
HTTP status code and the following body:
{
"id": "645b86cb3c2a798711ca40c1"
}
A new relationship with the id
645b86cb3c2a798711ca40c1
has now been created.
The response also includes the location response header that indicates the URL to the newly created relationship. So, the location header for the previous example would be http://public-api.eu.bluedolphin.app/v1/relations/645b86cb3c2a798711ca40c1
.
Comments
0 comments
Please sign in to leave a comment.