---
title: "Add edge definition"
method: POST
path: "/_fabric/{fabric}/_api/graph/{graph}/edge"
tags: ["Graphs"]
---

# Add edge definition

`POST /_fabric/{fabric}/_api/graph/{graph}/edge`

## Request

- The document declares no server URL.
- Auth: one of:
  - API key in header `Authorization`
  - HTTP bearer
- TypeScript: <https://skmtc.dev/macrometa/apis/macrometa-api-reference/docs/_fabric/:fabric/_api/graph/:graph/edge/post.ts> (a function with typed inputs; its response is checked against the schema)

Adds an additional edge definition to the graph.

This edge definition has to contain a *collection* and an array of each *from* and *to* vertex collections. An edge definition can only be added if this definition is either not used in any other graph, or it is used with exactly the same definition. It is not possible to store a definition "e" from "v1" to "v2" in the one graph, and "e" from "v2" to "v1" in the other graph.

**Note**: Requires *administrator* permissions.

## Path parameters

- `fabric` string, string, required
- `graph` string, string, required

## Request body

- GraphEdgeDefinitionAddHttpExamples
  - `collection` string, required: The name of the edge collection to be used.
  - `from` string[]: One or many vertex collections that can contain source vertices.
  - `to` string[]: One or many vertex collections that can contain target vertices.

## Response `201`

Successfully added edge when *waitForSync* is enabled.

- GraphEdgeDefinitionAddHttpExamplesRc201
  - `code` integer: HTTP response code.
  - `error` boolean, required: Flag if there is an error in response. *False* for this response.
  - `graph` GraphRepresentation: The information about the newly created graph.
    - `_id` string: The internal id value of this graph.
    - `_key` string: The key of this graph.
    - `_rev` string: The revision of this graph. Can be used to make sure to not override concurrent modifications to this graph.
    - `edgedefinitions` GraphEdgeDefinition[]: An array of definitions for the relations of the graph.
      - `collection` string: Name of the edge collection, where the edge are stored in.
      - `from` string[]: List of vertex collection names. Edges in collection can only be inserted if their _from is in any of the collections here.
      - `to` string[]: List of vertex collection names. Edges in collection can only be inserted if their _to is in any of the collections here.
    - `name` string: The name of the graph.
    - `orphanCollections` string[]: An array of additional vertex collections. Documents within these collections do not have edges within this graph.

## Other responses

- `202`: Successfully added edge when *waitForSync* is disabled.
- `400`: Failed due to missing, malformed data, or if the definition is used in another graph with a different signature. Verify that all parameters are complete.
- `403`: Failed to validate because you do not have access to the server.
- `404`: Failed to find the specified graph.

---

[API](https://skmtc.dev/macrometa/apis/macrometa-api-reference.md) - [All operations](https://skmtc.dev/macrometa/apis/macrometa-api-reference/llms.txt) - [OpenAPI document](https://skmtc.dev/macrometa/apis/macrometa-api-reference/revisions/2006b6d7f31d?raw)
