---
openapi: 3.0.3
info:
  title: Braze REST API – Delete user 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.user_relationships.bulk_delete` 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 type and the relationship type exist, whether the user and object exist, and whether the relationship exists, 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 delete of a relationship that doesn't exist yet waits instead of failing right away, because a request that creates the relationship might still be processing. A relationship whose object or user doesn't exist yet waits in the same way. 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/user_relationships:
    delete:
      summary: Delete user relationships in bulk
      operationId: bulkDeleteUserRelationships
      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` 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-ingestion-rejected` | Any other rejection, such as a refused `object_id`. |
        | `data-object-invalid-user-identifier` | A user identifier can't be used to find a user. |
        | `data-object-dependency-not-found` | The relationship, or its object or user, the record depends on was still missing after about 40 hours of retries. |
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BulkDeleteUserRelationshipsRequest'
            examples:
              by_external_id:
                summary: Unlink a user by external ID
                value:
                  records:
                  - type_name: account
                    object_id: acct-001
                    rel_kind: owns
                    user:
                      external_id: user-1
              by_braze_id:
                summary: Unlink a user by Braze ID
                value:
                  records:
                  - type_name: account
                    object_id: acct-001
                    rel_kind: owns
                    user:
                      braze_id: BRAZE_ID
              by_email:
                summary: Unlink a user by email address
                value:
                  records:
                  - type_name: account
                    object_id: acct-001
                    rel_kind: owns
                    user:
                      email: user@example.com
              by_phone:
                summary: Unlink a user by phone number
                value:
                  records:
                  - type_name: account
                    object_id: acct-001
                    rel_kind: owns
                    user:
                      phone: '+15555550100'
              by_alias:
                summary: Unlink a user by alias
                value:
                  records:
                  - type_name: account
                    object_id: acct-001
                    rel_kind: owns
                    user:
                      alias:
                        alias_name: anonymous_123
                        alias_label: temporary_id
              several:
                summary: Unlink several users in one request
                value:
                  records:
                  - type_name: account
                    object_id: acct-001
                    rel_kind: owns
                    user:
                      external_id: user-1
                  - type_name: account
                    object_id: acct-001
                    rel_kind: owns
                    user:
                      email: user@example.com
      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. Braze also returns it when a record's `user` has more than one identifier. For user relationships, `parameter` uses the request's own field names, such as `user.external_id`. Correct the record named by `index` and `parameter`.
            - **`missing-user-identifier`:** A record's `user` has no identifier. Include exactly one of `external_id`, `braze_id`, `email`, `phone`, or `alias`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorsResponse'
              examples:
                no_user_identifier:
                  summary: user has no identifier
                  value:
                    errors:
                    - index: 0
                      id: missing-user-identifier
                      parameter: user
                      message: user must contain exactly one of external_id, braze_id, alias, email, phone
                several_user_identifiers:
                  summary: user has more than one identifier
                  value:
                    errors:
                    - index: 0
                      id: schema-mismatch
                      parameter: user
                      message: user must contain exactly one of external_id, braze_id, alias, email, phone
                missing_user:
                  summary: Record missing user
                  value:
                    errors:
                    - index: 0
                      id: schema-mismatch
                      parameter: user
                      message: user is required
                unrecognized_user_field:
                  summary: Unrecognized field in user
                  value:
                    errors:
                    - index: 0
                      id: schema-mismatch
                      parameter: user.user_id
                      message: user.user_id is not a recognized field
                missing_field:
                  summary: Record missing a required field
                  value:
                    errors:
                    - index: 0
                      id: schema-mismatch
                      parameter: rel_kind
                      message: rel_kind is required
                attributes_sent:
                  summary: Record includes attributes
                  value:
                    errors:
                    - index: 0
                      id: schema-mismatch
                      parameter: attributes
                      message: attributes is not a recognized field
                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: user.email
                      message: user.email 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.user_relationships.bulk_delete` 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.user_relationships.bulk_delete` permission. Pass the key as `Authorization: Bearer YOUR-REST-API-KEY`.
  schemas:
    UserRelationshipDeleteRecord:
      title: User relationship delete record
      type: object
      required:
      - type_name
      - object_id
      - rel_kind
      - user
      additionalProperties: false
      properties:
        type_name:
          type: string
          minLength: 1
          description: Type of the object the user is linked to.
          example: account
        object_id:
          type: string
          minLength: 1
          description: Identifier of the object the user is linked to.
          example: acct-001
        rel_kind:
          type: string
          minLength: 1
          description: Name of the relationship type. To list valid values, use [List user relationship types]({{site.baseurl}}/api/endpoints/data_objects/types/get_list_user_relationship_types).
          example: owns
        user:
          $ref: '#/components/schemas/UserIdentifier'
    BulkDeleteUserRelationshipsRequest:
      title: Delete user relationships in bulk request
      type: object
      required:
      - records
      additionalProperties: false
      properties:
        records:
          type: array
          minItems: 1
          maxItems: 50
          description: 1 to 50 user relationship records. Any other top-level field is rejected.
          items:
            $ref: '#/components/schemas/UserRelationshipDeleteRecord'
    UserAlias:
      title: User alias
      type: object
      required:
      - alias_name
      - alias_label
      additionalProperties: false
      description: The user's alias. Both fields are required.
      properties:
        alias_name:
          type: string
          minLength: 1
          example: anonymous_123
        alias_label:
          type: string
          minLength: 1
          example: temporary_id
    UserIdentifier:
      title: User identifier
      description: |
        The user to link. Include exactly one identifier: `external_id`, `braze_id`, `email`, `phone`, or `alias`. A `user` with no identifier returns `missing-user-identifier`, and a `user` with more than one returns `schema-mismatch`.
      oneOf:
      - title: By external ID
        type: object
        required:
        - external_id
        additionalProperties: false
        properties:
          external_id:
            type: string
            minLength: 1
            description: The user's external ID.
            example: user-1
      - title: By Braze ID
        type: object
        required:
        - braze_id
        additionalProperties: false
        properties:
          braze_id:
            type: string
            minLength: 1
            description: The user's Braze ID.
            example: BRAZE_ID
      - title: By email address
        type: object
        required:
        - email
        additionalProperties: false
        properties:
          email:
            type: string
            minLength: 1
            description: The user's email address. When several users share it, the standard Braze profile-selection rules decide which one is used.
            example: user@example.com
      - title: By phone number
        type: object
        required:
        - phone
        additionalProperties: false
        properties:
          phone:
            type: string
            minLength: 1
            description: The user's phone number. When several users share it, the standard Braze profile-selection rules decide which one is used.
            example: '+15555550100'
      - title: By user alias
        type: object
        required:
        - alias
        additionalProperties: false
        properties:
          alias:
            $ref: '#/components/schemas/UserAlias'
    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
