---
title: "executeRelations"
method: POST
path: "/v1/relations:execute"
tags: ["mappings"]
---

# executeRelations

`POST /v1/relations:execute`

Execute relation mapping between source entity and target entities

## Request body

- ExecuteRelationsReq — Build relations between a source entity and one or more target entities, dynamically identified
  - `source_ref` EntityRef, required
    - `entity_id` string, required — id of the source entity to be mapped
    - `entity_schema` string — schema of the source entity
  - `target` object
    - `main_entity_ref` EntityRef, required
      - `entity_id` string, required — id of the source entity to be mapped
      - `entity_schema` string — schema of the source entity
    - `relation_attributes` RelationAttribute[], required — Relation mappings
      - `target` string, required — Target attribute to store the relation in
      - `target_tags` string[] — Relation tags (labels) to set for the stored relations
      - `target_tags_include_source` boolean — Include all relation tags (labels) present on the main entity relation
      - `target_entity_tags` string[] — Tags to add to the matched target entity's _tags array during mapping. Useful for assigning file collections to file entities.
      - `override_with_source_filter` boolean — Whether to override the relation source_filter with the specified one
      - `source_filter` object — A filter to identify which source entities to pick as relations from main entity
        - `limit` integer — Limit relations to maximum number (default, all matched relations)
        - `schema` string — Filter by specific schema
        - `attribute` string — Filter by a specific relation attribute on the main entity
        - `relation_tag` string — Filter by relation tag (label) on the main entity
        - `tag` string — Filter by a specific tag on the related entity
        - `self` boolean — Picks main entity as relation (overrides other filters)
      - `related_to` object
      - `mode` 'append' | 'prepend' | 'set', required
      - `origin` 'system_recommendation' | 'user_manually' | 'entity_updating_system_recommendation' — Origin of an attribute.
    - `linkback` object — For cases where you want to store a relation between main entity (eg. submission) and current source entity.
      - `attribute` string, required — Relation attribute on the main entity (submission) where the target entity will be linked. Set to false to disable linkback
      - `relation_tags` string[], required — Relation tags (labels) to include in main entity linkback relation attribute
  - `additional_relations` RelationItem[]
    - `entity_id` string, required
    - `attribute` string, required

## Response `200`

The relations which were for both source entity and main entity

- ExecuteRelationsResp
  - `relations` NewRelationItem[]
    - `source_entity_id` string, required
    - `target_entity_id` string, required
    - `relation_attr` string, required
    - `tags` string[]

---

[API](https://skmtc.dev/epilot/apis/entity-mapping-api.md) · [All operations](https://skmtc.dev/epilot/apis/entity-mapping-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/epilot/entity-mapping-api/revisions/ac038dfc97a1/schema)
