---
title: "Create an edge"
method: POST
path: "/_fabric/{fabric}/_api/graph/{graph}/edge/{edgeCollection}"
tags: ["Graphs"]
---

# Create an edge

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

## 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/:edgeCollection/post.ts> (a function with typed inputs; its response is checked against the schema)

Create a new edge in the collection.

**Note:** Requires *Read Only* permissions on the GeoFabric and *Write* access on the collection.

## Path parameters

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

## Query parameters

- `returnNew` boolean

## Request body

- GraphEdgeCreateHttpExamples
  - `_from` string, required: The source vertex of this edge. Has to be valid within the used edge definition.
  - `_to` string: The target vertex of this edge. Has to be valid within the used edge definition.

## Response `201`

Successfully created the edge when *waitForSync* is enabled.

- GraphEdgeCreateHttpExamplesRc201
  - `code` integer: HTTP response code.
  - `error` boolean, required: Flag if there is an error in response. *False* for this response.
  - `edge` EdgeRepresentation: The edge document.
    - `_id` string: The _id value of the stored data.
    - `_key` string: The _key-value of the stored data.
    - `_rev` string: The _rev value of the stored data.
    - `_from` string: The _from value of the stored data.
    - `_to` string: The _to value of the stored data.
  - `new` EdgeRepresentationNew: The edge document.
    - `_id` string: The _id value of the stored data.
    - `_key` string: The _key-value of the stored data.
    - `_rev` string: The _rev value of the stored data.
    - `_from` string: The _from value of the stored data.
    - `_to` string: The _to value of the stored data.

## Other responses

- `202`: Successfully created the edge when *waitForSync* is disabled.
- `400`: Failed due to missing or malformed data. Verify that all parameters are complete.
- `403`: Failed to validate because you do not have access to the server.
- `404`: Failed to find graph, edge collection, `_from` or `_to`.

---

[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)
