---
openapi: 3.0.3
info:
  title: Braze REST API – Create or replace object relationships in bulk
  description: |
    ## Prerequisites

    To use this endpoint, you'll need an [API key]({{site.baseurl}}/api/basics#rest-api-key-permissions) with the `data_objects.object_relationships.bulk_upsert` permission. The bulk endpoints use their own permissions: the single-record Data Objects permissions, such as `data_objects.create`, don't grant access to them.

    ## Rate limit

    We apply a shared rate limit of 1,000 requests per minute per workspace to this endpoint. The limit is shared across all six Data Objects bulk endpoints and with Cloud Data Ingestion syncs of data objects. It's separate from the 1,000 requests per minute limit on the single-record Data Objects write endpoints.

    Every response includes the `X-RateLimit-Limit`, `X-RateLimit-Remaining`, and `X-RateLimit-Reset` headers. A `429` response also includes `X-RateLimit-Retry-After`, the number of seconds to wait before you retry. For more information, see [API rate limits]({{site.baseurl}}/api/api_limits).

    ## Validation is all-or-nothing

    Braze checks the shape of every record when it receives the request. If any record fails, Braze rejects the whole request with `400` and stores nothing. Braze checks the request in stages and lists every error it finds at the stage that fails. After you fix those errors and resend the whole request, a later stage can still return new errors.

    ## Processing is asynchronous

    A `202` response means Braze accepted the batch and queued it for processing. It doesn't mean the records were applied. Braze runs lookups, such as whether the types and the relationship type exist, and whether the attributes match the relationship type's fields, when it processes the batch, so a request that returns `202` can still produce failures for individual records later. For the codes Braze records, see [Processing failure codes](#processing-failure-codes).

    ## Ordering

    Braze stamps every record with the time it received the request. Don't send `updated_at` in a record; Braze rejects it. When two requests change the same relationship, the request Braze received later wins, and an older write that arrives afterward is skipped.

    ## Waiting on dependencies

    A relationship whose source or target object doesn't exist yet waits instead of failing right away, because a request that creates it might still be processing. Braze retries for about 40 hours (10 attempts). If the dependency still doesn't exist after that, the record fails with `data-object-dependency-not-found`.

    ## Product limits

    The same limits as the single-record Data Objects endpoints apply: 50,000 data object records per company, 1,000 data objects per user, 10,000 users per data object, 1,000 related objects per data object, and 255 characters per attribute value. For details, see [Product limits]({{site.baseurl}}/api/endpoints/data_objects#product-limits).
  version: 1.0.0
  contact:
    name: Braze Support
    url: https://www.braze.com/docs/braze_support/
  license:
    name: Braze Documentation
    url: https://www.braze.com/docs/api/home/
servers:
- url: https://rest.iad-01.braze.com
  description: US-01
- url: https://rest.iad-02.braze.com
  description: US-02
- url: https://rest.iad-03.braze.com
  description: US-03
- url: https://rest.iad-04.braze.com
  description: US-04
- url: https://rest.iad-05.braze.com
  description: US-05
- url: https://rest.iad-06.braze.com
  description: US-06
- url: https://rest.iad-07.braze.com
  description: US-07
- url: https://rest.iad-08.braze.com
  description: US-08
- url: https://rest.us-10.braze.com
  description: US-10
- url: https://rest.fra-01.braze.eu
  description: EU-01
- url: https://rest.fra-02.braze.eu
  description: EU-02
- url: https://rest.au-01.braze.com
  description: AU-01
- url: https://rest.id-01.braze.com
  description: ID-01
- url: https://rest.jp-01.braze.com
  description: JP-01
- url: https://rest.kr-01.braze.com
  description: KR-01
security:
- BearerAuth: []
paths:
  /data_objects/object_relationships:
    put:
      summary: Create or replace object relationships in bulk
      operationId: bulkUpsertObjectRelationships
      description: |
        ## Processing failure codes

        These codes aren't returned by the endpoint. Braze records them for each record that fails when it processes a queued batch. The codes are stable, so you can rely on their exact values.

        | Code | Meaning |
        |---|---|
        | `data-object-type-not-found` | `type_name` or `related_type_name` names no active data object type in the workspace. |
        | `data-object-relationship-type-not-found` | `rel_kind` names no active relationship type for these types. |
        | `data-object-schema-mismatch` | `attributes` don't match the relationship type's fields. The message names every attribute at fault. |
        | `data-object-ingestion-rejected` | Any other rejection, such as a refused `object_id`. |
        | `data-object-dependency-not-found` | The source or target object the record depends on was still missing after about 40 hours of retries. |
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BulkUpsertObjectRelationshipsRequest'
            examples:
              with_attributes:
                summary: Create or replace a relationship with attributes
                value:
                  records:
                  - type_name: contact
                    object_id: contact-001
                    rel_kind: works_at
                    related_type_name: account
                    related_object_id: acct-001
                    attributes:
                      since: '2024-01-15T00:00:00Z'
              without_attributes:
                summary: Relationship type with no fields
                value:
                  records:
                  - type_name: account
                    object_id: acct-001
                    rel_kind: subaccount
                    related_type_name: account
                    related_object_id: acct-002
                    attributes: {}
              several:
                summary: Several relationships in one request
                value:
                  records:
                  - type_name: contact
                    object_id: contact-001
                    rel_kind: works_at
                    related_type_name: account
                    related_object_id: acct-001
                    attributes:
                      since: '2024-01-15T00:00:00Z'
                  - type_name: contact
                    object_id: contact-002
                    rel_kind: works_at
                    related_type_name: account
                    related_object_id: acct-001
                    attributes:
                      since: '2025-03-01T00:00:00Z'
      responses:
        '202':
          description: |
            Accepted. Braze queued the batch for processing. Records are applied later, and individual records can still fail during processing. See [Processing failure codes](#processing-failure-codes).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AcceptedResponse'
              examples:
                queued:
                  summary: Batch queued
                  value:
                    source_import_id: api-20261022T153012123456-9f3a1c2b
                    status: queued
                    record_count: 2
        '400':
          description: |
            Bad request. Braze stored nothing. Each error has an `id`, a `message`, the `parameter` at fault when there is one, and, for record-level errors, the record's `index` (its 0-based position in `records`). Fix every error and resend the whole request.

            - **`invalid-request`:** The body isn't a JSON object or is malformed JSON, `records` is missing or has fewer than 1 or more than 50 entries, or the body has a top-level field other than `records`, including a field Braze sets (`source_type`, `source_import_id`, `source_chunk_id`, or `record_type`). Send a JSON object whose only field is `records`, with 1 to 50 entries.
            - **`schema-mismatch`:** A record is missing a required field, has an unrecognized field (including `updated_at`), has a field of the wrong type or an empty string, or has a value or field name that isn't valid UTF-8 or contains the null character. Correct the record named by `index` and `parameter`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorsResponse'
              examples:
                missing_field:
                  summary: Record missing a required field
                  value:
                    errors:
                    - index: 0
                      id: schema-mismatch
                      parameter: rel_kind
                      message: rel_kind is required
                missing_attributes:
                  summary: Record missing attributes
                  value:
                    errors:
                    - index: 0
                      id: schema-mismatch
                      parameter: attributes
                      message: attributes is required
                too_many_records:
                  summary: records has more than 50 entries
                  value:
                    errors:
                    - id: invalid-request
                      parameter: records
                      message: records must contain between 1 and 50 entries
                missing_records:
                  summary: records is missing
                  value:
                    errors:
                    - id: invalid-request
                      parameter: records
                      message: records is required
                unrecognized_top_level_field:
                  summary: Unrecognized top-level field
                  value:
                    errors:
                    - id: invalid-request
                      parameter: batch_name
                      message: batch_name is not a recognized field
                server_set_field:
                  summary: Field that Braze sets
                  value:
                    errors:
                    - id: invalid-request
                      parameter: source_import_id
                      message: source_import_id is not a recognized field
                malformed_json:
                  summary: Malformed JSON
                  value:
                    errors:
                    - id: invalid-request
                      message: The request contains malformed JSON.
                body_not_object:
                  summary: Body isn't a JSON object
                  value:
                    errors:
                    - id: invalid-request
                      message: The request body must be a JSON object
                record_not_object:
                  summary: Record isn't a JSON object
                  value:
                    errors:
                    - index: 0
                      id: schema-mismatch
                      message: The record must be a JSON object
                updated_at_sent:
                  summary: Record includes updated_at
                  value:
                    errors:
                    - index: 0
                      id: schema-mismatch
                      parameter: updated_at
                      message: updated_at is not a recognized field
                empty_string:
                  summary: Empty string
                  value:
                    errors:
                    - index: 0
                      id: schema-mismatch
                      parameter: object_id
                      message: object_id must not be empty
                wrong_type:
                  summary: Field of the wrong type
                  value:
                    errors:
                    - index: 0
                      id: schema-mismatch
                      parameter: object_id
                      message: object_id must be string
                invalid_characters:
                  summary: Record value that isn't valid UTF-8
                  value:
                    errors:
                    - index: 0
                      id: schema-mismatch
                      parameter: object_id
                      message: object_id must be valid UTF-8
        '401':
          description: |
            Unauthorized. The REST API key is missing or invalid. Send the key as `Authorization: Bearer YOUR-REST-API-KEY` to the correct [REST endpoint]({{site.baseurl}}/api/basics/#endpoints).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthErrorResponse'
              examples:
                invalid_api_key:
                  summary: Missing or invalid API key
                  value:
                    error: Error authenticating credentials
        '403':
          description: |
            Forbidden. To resolve it:

            - **The API key doesn't have the required permission:** Use a REST API key with the `data_objects.object_relationships.bulk_upsert` permission.
            - **The request came from an IP address the key doesn't allow:** Send the request from an IP address on the key's allowlist, or update the allowlist.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthErrorResponse'
              examples:
                missing_permission:
                  summary: Missing permission
                  value:
                    error: You do not have permission to access this resource
                ip_not_allowed:
                  summary: IP address not on the allowlist
                  value:
                    error: IP address 192.0.2.10 is not whitelisted
        '404':
          description: |
            Not found. Data Objects isn't enabled for your company. Your workspace must be provisioned for Accounts. See [Enable Accounts]({{site.baseurl}}/user_guide/data/activation/accounts#step-1-enable-accounts).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundResponse'
              examples:
                not_enabled:
                  summary: Data Objects not enabled
                  value:
                    message: Invalid URL
        '429':
          description: |
            Rate limited. You exceeded the shared limit of 1,000 requests per minute for the Data Objects bulk endpoints. Wait the number of seconds in the `X-RateLimit-Retry-After` header, then retry at a lower rate. See [API rate limits]({{site.baseurl}}/api/api_limits).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorsResponse'
              examples:
                over_rate_limit:
                  summary: Over rate limit
                  value:
                    errors:
                    - id: rate-limit-exceeded
                      message: You have exceeded your limit of 1000 requests per minute. Please contact your account executive to increase your limit. If you do not have their info, you may contact Braze directly at https://www.braze.com/contact/.
        '500':
          description: |
            Internal server error. Braze didn't accept the batch, so nothing was queued. Retrying the request is safe.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorsResponse'
              examples:
                internal_error:
                  summary: Batch not accepted
                  value:
                    errors:
                    - id: internal-error
                      message: The batch could not be accepted. Retry the request.
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: REST API key
      description: |
        REST API keys are created in the Braze dashboard at **Settings** > **APIs and Identifiers** > **API Keys**. The key must include the `data_objects.object_relationships.bulk_upsert` permission. Pass the key as `Authorization: Bearer YOUR-REST-API-KEY`.
  schemas:
    ObjectRelationshipUpsertRecord:
      title: Object relationship upsert record
      type: object
      required:
      - type_name
      - object_id
      - rel_kind
      - related_type_name
      - related_object_id
      - attributes
      additionalProperties: false
      properties:
        type_name:
          type: string
          minLength: 1
          description: Type of the source object.
          example: contact
        object_id:
          type: string
          minLength: 1
          description: Identifier of the source object.
          example: contact-001
        rel_kind:
          type: string
          minLength: 1
          description: Name of the relationship type. To list valid values, use [List object relationship types]({{site.baseurl}}/api/endpoints/data_objects/types/get_list_object_relationship_types).
          example: works_at
        related_type_name:
          type: string
          minLength: 1
          description: Type of the target object.
          example: account
        related_object_id:
          type: string
          minLength: 1
          description: Identifier of the target object.
          example: acct-001
        attributes:
          type: object
          additionalProperties: true
          description: 'The relationship''s attributes, keyed by field name. Send `{}` if the relationship type has no fields. Date fields must be RFC 3339 date-time strings that include a time and time zone, such as `2026-11-03T00:00:00Z`. Braze checks attributes when it processes the batch, so a request with a date-only value such as `2026-11-03` still returns `202`, and Braze records a `data-object-schema-mismatch` [processing failure](#processing-failure-codes) for that record. For details, see [Date field format]({{site.baseurl}}/api/endpoints/data_objects#date-field-format).'
          example:
            since: '2024-01-15T00:00:00Z'
    BulkUpsertObjectRelationshipsRequest:
      title: Create or replace object relationships in bulk request
      type: object
      required:
      - records
      additionalProperties: false
      properties:
        records:
          type: array
          minItems: 1
          maxItems: 50
          description: 1 to 50 object relationship records. Any other top-level field is rejected.
          items:
            $ref: '#/components/schemas/ObjectRelationshipUpsertRecord'
    RecordError:
      title: Error
      type: object
      required:
      - id
      - message
      properties:
        index:
          type: integer
          minimum: 0
          description: The 0-based position of the record in `records`. Present on record-level errors only.
          example: 0
        id:
          type: string
          description: The error ID.
          example: schema-mismatch
        parameter:
          type: string
          description: The field at fault, when there is one.
          example: object_id
        message:
          type: string
          description: A description of the error.
          example: object_id is required
    ErrorsResponse:
      title: Errors response
      type: object
      required:
      - errors
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/RecordError'
    AuthErrorResponse:
      title: Authorization error
      type: object
      properties:
        error:
          type: string
          description: A description of the error.
    NotFoundResponse:
      title: Not found
      type: object
      properties:
        message:
          type: string
          example: Invalid URL
    AcceptedResponse:
      title: Accepted response
      type: object
      required:
      - source_import_id
      - status
      - record_count
      properties:
        source_import_id:
          type: string
          description: The ID Braze generated for this request. Every request is its own import.
          example: api-20261022T153012123456-9f3a1c2b
        status:
          type: string
          enum:
          - queued
          description: 'Always `queued`: the batch was accepted and queued for processing.'
          example: queued
        record_count:
          type: integer
          minimum: 1
          maximum: 50
          description: The number of records accepted.
          example: 2
