---
openapi: 3.0.3
info:
  title: "Braze REST API \u2013 List user relationships"
  description: |
    ## Prerequisites

    To use this endpoint, you need an [API key]({{site.baseurl}}/api/basics#rest-api-key-permissions) with `data_objects.user_relationships.read`.

    ## Rate limit

    This endpoint is in the Data Objects read bucket with a default limit of 1000 requests per minute.
  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/objects/{type_name}/{object_id}/user_relationships:
    get:
      summary: List user relationships
      operationId: get_data_objects_objects_type_name_object_id_user_relationships_get_list_user_relationships
      parameters:
        - name: type_name
          in: path
          required: true
          description: Object type
          schema:
            type: string
          example: account
        - name: object_id
          in: path
          required: true
          description: Object identifier
          schema:
            type: string
          example: acct-123
        - name: rel_kind
          in: query
          required: false
          description: Filter by relationship kind
          schema:
            type: string
          example: account_user
        - name: limit
          in: query
          required: false
          description: Page size. Default `100`. Values above `250` are treated as `250`. Values below `1` return a `400` error.
          schema:
            type: integer
            minimum: 1
            default: 100
          example: 100
        - name: offset
          in: query
          required: false
          description: Offset. Default `0`. Negative values are floored to `0`
          schema:
            type: integer
            default: 0
          example: 0
      responses:
        "200":
          description: |
            OK. The response body includes the users linked to the data object. No action needed.

            This section includes a sample successful response and the response fields.

            The status code `200` could return the following response body. This example lists the users linked to `acct-123` through the `account_user` relationship.

            The `user` payload contains `braze_id`, plus the user's `external_id` and `email` when the profile has them.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListUserRelationshipsResponse'
              examples:
                success:
                  summary: Example success response
                  value:
                    items:
                      - type_name: account
                        object_id: acct-123
                        rel_kind: account_user
                        user:
                          braze_id: 507f1f77bcf86cd799439011
                        attributes:
                          role: admin
                    total_count: 1
                    has_more: false
                    next_offset: null
                    offset: 0
                    limit: 100
        "400":
          description: |
            Bad request. A value or field name in the request body, path, or query isn't valid UTF-8 or contains the null character. Remove the invalid characters. The `invalid_request` error names each affected field in `source` and doesn't include the value.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_characters:
                  summary: Value isn't valid UTF-8
                  value:
                    errors:
                      - id: 3f0c7a52-9b1e-4d6a-8c2f-5e7b1a9d4c60
                        status_code: 400
                        error_code: invalid_request
                        message: object_id must be valid UTF-8
                        source:
                          path: object_id
        "401":
          description: |
            Unauthorized. Missing or invalid REST API key. Verify the `Authorization` header uses `Bearer YOUR_REST_API_KEY` and that the key is active.

            The REST API key is missing, malformed, or sent to the wrong REST endpoint. Send the key to the correct [REST endpoint]({{site.baseurl}}/api/basics/#endpoints).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_api_key:
                  summary: Missing or invalid API key
                  value:
                    error: Error authenticating credentials
        "403":
          description: |
            Forbidden. API key lacks permission or request is blocked by allowlist. Confirm the key has `data_objects.user_relationships.read` and that your source IP is on the key allowlist, if configured.

            This status means the REST API key doesn't have the required permission, or the request came from an IP address that isn't on the key's allowlist.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                access_denied:
                  summary: Missing permission
                  value:
                    error: You do not have permission to access this resource
                ip_not_allowed:
                  summary: Source IP not on the allowlist
                  value:
                    error: IP address 203.0.113.10 is not whitelisted
        "404":
          description: Not found. Type or object not found. Confirm `type_name` and `object_id` both exist in the workspace.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                type_not_found:
                  summary: Type not found
                  value:
                    errors:
                      - id: data-object-type-not-found
                        message: Data object type not found.
                        parameters:
                          - type_name
                        parameter_values:
                          - account
                object_not_found:
                  summary: Object not found
                  value:
                    errors:
                      - id: data-object-not-found
                        message: Data object not found.
                        parameters:
                          - type_name
                          - object_id
                        parameter_values:
                          - account
                          - acct-123
        "429":
          description: |
            Too many requests. Rate limit exceeded. Retry after `X-RateLimit-Reset` and reduce request frequency.

            You exceeded the rate limit for this endpoint. See [API rate limits]({{site.baseurl}}/api/api_limits/).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              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/.
        5XX:
          description: |
            Internal server error. An unexpected error occurred on the Braze server. Retry with exponential backoff. If the error persists, contact [Support]({{site.baseurl}}/braze_support/).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
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.read` permission.
        Pass the key as `Authorization: Bearer YOUR_REST_API_KEY`.
  schemas:
    ListedUser:
      title: Linked user
      type: object
      description: Linked user object
      required: [braze_id]
      properties:
        braze_id:
          type: string
          description: Braze user identifier
        external_id:
          type: string
          nullable: true
          description: The user's external ID, or `null` if the profile has none
        email:
          type: string
          nullable: true
          description: The user's email address, or `null` if the profile has none
          example: 507f1f77bcf86cd799439011
    ListedUserRelationship:
      title: User relationship
      type: object
      required: [type_name, object_id, rel_kind, user, attributes]
      properties:
        type_name:
          type: string
          description: Data object type machine name
          example: account
        object_id:
          type: string
          description: Data object identifier
          example: acct-123
        rel_kind:
          type: string
          description: Relationship kind value
          example: account_user
        user:
          $ref: '#/components/schemas/ListedUser'
        attributes:
          type: object
          additionalProperties: true
          description: Relationship attributes
          example:
            role: admin
    ListUserRelationshipsResponse:
      title: List user relationships response
      type: object
      required: [items, total_count, has_more, offset, limit]
      properties:
        items:
          type: array
          description: List of user relationship records
          items:
            $ref: '#/components/schemas/ListedUserRelationship'
        total_count:
          type: integer
          description: Total number of matching records
          example: 1
        has_more:
          type: boolean
          description: Whether another page of results is available
          example: false
        next_offset:
          type: integer
          nullable: true
          description: Offset for the next page when `has_more` is `true`
          example: null
        offset:
          type: integer
          description: Current page offset
          example: 0
        limit:
          type: integer
          description: Page size used by the request
          example: 100
    ErrorResponse:
      title: Error
      type: object
      properties:
        error:
          type: string
          description: Error message returned for authentication and permission errors.
        message:
          type: string
          description: Human-readable error message.
        errors:
          type: array
          description: Optional list of detailed validation errors. Each entry has an `id` and a human-readable `message`, and may name the request `parameters` it applies to.
          items:
            type: object
            properties:
              id:
                type: string
                description: Error identifier, such as `data-object-not-found`.
              message:
                type: string
                description: Human-readable error message.
              parameters:
                type: array
                description: The request parameters the error applies to.
                items:
                  type: string
              parameter_values:
                type: array
                description: The values sent for those parameters.
                items:
                  type: string
              status_code:
                type: integer
                description: HTTP status code. Included with `invalid_request` errors.
                example: 400
              error_code:
                type: string
                description: Error code, such as `invalid_request`. When it's present, `id` is a unique identifier for this error occurrence.
                example: invalid_request
              source:
                title: Error source
                type: object
                description: The request field the error applies to. Included with `invalid_request` errors.
                properties:
                  path:
                    type: string
                    description: Dot-separated path to the field, such as `attributes.name`, when one field is affected.
                  paths:
                    type: array
                    description: Dot-separated paths to each field, when more than one field is affected.
                    items:
                      type: string
