API Reference - Tag Relationships

Link: https://support.brilliantdirectories.com/support/solutions/articles/12000108062

← Back to API Reference | Getting Started

Tag Relationships

Tag Relationships link individual tags to specific objects (such as members) on your directory. Each record associates a tag with an object ID and specifies the tag type, enabling flexible many-to-many tag assignments across different object types.

Model name in URL: rel_tags — DB table: rel_tags

The Tag Relationship Object

FieldTypeDescription
idintegerUnique tag relationship ID (primary key, read-only)
tag_idstringID of the tag being applied (foreign key to tags)
object_idintegerID of the object the tag is applied to (foreign key referencing the table in tag_types.table_relation)
tag_type_idintegerID of the tag type that defines what kind of object is being tagged (foreign key to tag_types)
added_byintegerUser ID of the user who created this tag relationship
created_atdatetimeTimestamp when this tag relationship was created

List Tag Relationship Records

GET /api/v2/rel_tags/get

Returns a paginated list of tag relationship records.

Example Request

Copy
curl -X GET "https://www.yourdomain.com/api/v2/rel_tags/get?limit=25" \
  -H "X-Api-Key: your-api-key-here"

Example Response

Copy
{
  "status": "success",
  "message": [
    {
      "id": "2",
      "tag_id": "1",
      "object_id": "1096",
      "tag_type_id": "1",
      "added_by": "27",
      "created_at": "2024-06-04 16:36:35"
    },
    {
      "id": "3",
      "tag_id": "1",
      "object_id": "1095",
      "tag_type_id": "1",
      "added_by": "27",
      "created_at": "2024-06-04 16:36:35"
    }
  ],
  "total": "1476",
  "current_page": 1,
  "total_pages": 492,
  "next_page": "MipfKjM="
}

Retrieve a Tag Relationship Record

GET /api/v2/rel_tags/get/{id}

Example Request

Copy
curl -X GET "https://www.yourdomain.com/api/v2/rel_tags/get/2" \
  -H "X-Api-Key: your-api-key-here"

Example Response

Copy
{
  "status": "success",
  "message": [
    {
      "id": "2",
      "tag_id": "1",
      "object_id": "1096",
      "tag_type_id": "1",
      "added_by": "27",
      "created_at": "2024-06-04 16:36:35"
    }
  ],
  "total": "1476",
  "current_page": 1,
  "total_pages": 60,
  "next_page": "MipfKjI1"
}

Create a Tag Relationship Record

POST /api/v2/rel_tags/create

Applies a tag to an object by creating a tag relationship record.

Example Request

Copy
curl -X POST "https://www.yourdomain.com/api/v2/rel_tags/create" \
  -H "X-Api-Key: your-api-key-here" \
  -d "tag_id=1" \
  -d "object_id=500" \
  -d "tag_type_id=1" \
  -d "added_by=1"

Example Response

Copy
{
  "status": "success",
  "message": {
    "id": "1479",
    "tag_id": "1",
    "object_id": "500",
    "tag_type_id": "1",
    "added_by": "1",
    "created_at": null
  }
}

Update a Tag Relationship Record

PUT /api/v2/rel_tags/update

Example Request

Copy
curl -X PUT "https://www.yourdomain.com/api/v2/rel_tags/update" \
  -H "X-Api-Key: your-api-key-here" \
  -d "id=1479" \
  -d "object_id=501"

Example Response

Copy
{
  "status": "success",
  "message": {
    "id": "1479",
    "tag_id": "1",
    "object_id": "501",
    "tag_type_id": "1",
    "added_by": "1",
    "created_at": "0000-00-00 00:00:00"
  }
}

Delete a Tag Relationship Record

DELETE /api/v2/rel_tags/delete

Example Request

Copy
curl -X DELETE "https://www.yourdomain.com/api/v2/rel_tags/delete" \
  -H "X-Api-Key: your-api-key-here" \
  -d "id=1479"

Example Response

Copy
{
  "status": "success",
  "message": "rel_tags record was deleted"
}