> ## Documentation Index
> Fetch the complete documentation index at: https://docs.myme.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Bulk upsert edges

> Creates or upserts up to 5000 edges in one call. Sibling to `POST /items/bulk` for the graph half of tenant migrations — items created in an earlier bulk call exist on the server; a second pass through this endpoint wires them together without having to hold source and target in the same payload.

Modes: `upsert` (default) matches existing rows on `(source_id, target_id, edge_type)` and replaces `properties` in place; `create_only` surfaces matching rows as `skipped` with reason `duplicate_edge`. Atomic by default — any failure rolls back the batch. Set `atomic: false` to run per-edge with per-edge outcomes. `emit_events: true` fires an `edge.created` webhook per newly-created edge; `updated` outcomes emit nothing.

Admin-only. See [Bulk operations](/api/bulk-operations) for outcome shape and event semantics.



## OpenAPI

````yaml /openapi.json post /edges/bulk
openapi: 3.1.0
info:
  title: Marfa API
  version: 4.2.0
  description: Typed data layer for structured personal data
servers: []
security: []
paths:
  /edges/bulk:
    post:
      tags:
        - Edges
      summary: Bulk upsert edges
      description: >-
        Creates or upserts up to 5000 edges in one call. Sibling to `POST
        /items/bulk` for the graph half of tenant migrations — items created in
        an earlier bulk call exist on the server; a second pass through this
        endpoint wires them together without having to hold source and target in
        the same payload.


        Modes: `upsert` (default) matches existing rows on `(source_id,
        target_id, edge_type)` and replaces `properties` in place; `create_only`
        surfaces matching rows as `skipped` with reason `duplicate_edge`. Atomic
        by default — any failure rolls back the batch. Set `atomic: false` to
        run per-edge with per-edge outcomes. `emit_events: true` fires an
        `edge.created` webhook per newly-created edge; `updated` outcomes emit
        nothing.


        Admin-only. See [Bulk operations](/api/bulk-operations) for outcome
        shape and event semantics.
      operationId: bulkUpsertEdges
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                edges:
                  type: array
                  items:
                    type: object
                    properties:
                      id:
                        type: string
                      source_id:
                        type: string
                      target_id:
                        type: string
                      edge_type:
                        type: string
                      properties:
                        type: object
                        additionalProperties:
                          nullable: true
                    required:
                      - source_id
                      - target_id
                      - edge_type
                mode:
                  type: string
                  enum:
                    - upsert
                    - create_only
                atomic:
                  type: boolean
                emit_events:
                  type: boolean
              required:
                - edges
      responses:
        '200':
          description: Bulk edge result
          content:
            application/json:
              schema:
                type: object
                properties:
                  counts:
                    type: object
                    properties:
                      created:
                        type: integer
                      updated:
                        type: integer
                      skipped:
                        type: integer
                      errored:
                        type: integer
                    required:
                      - created
                      - updated
                      - skipped
                      - errored
                  results:
                    type: array
                    items:
                      type: object
                      properties:
                        index:
                          type: integer
                        outcome:
                          type: string
                          enum:
                            - created
                            - updated
                            - skipped
                            - errored
                        id:
                          type: string
                        reason:
                          type: string
                        error:
                          type: object
                          properties:
                            code:
                              type: string
                            message:
                              type: string
                          required:
                            - code
                            - message
                      required:
                        - index
                        - outcome
                required:
                  - counts
                  - results
        '400':
          description: Validation error or atomic rollback
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - validation_error
                          - missing_required_field
                          - bulk_atomic_rollback
                      message:
                        type: string
                      details:
                        type: object
                        additionalProperties:
                          nullable: true
                    required:
                      - code
                      - message
                required:
                  - error
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - unauthorized
                      message:
                        type: string
                      details:
                        type: object
                        additionalProperties:
                          nullable: true
                    required:
                      - code
                      - message
                required:
                  - error
        '403':
          description: Admin required
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - forbidden
                      message:
                        type: string
                      details:
                        type: object
                        additionalProperties:
                          nullable: true
                    required:
                      - code
                      - message
                required:
                  - error
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key or OAuth Token
      description: Pass an API key (marfa_k1_...) or OAuth access token (marfa_at_...)

````