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

# Upsert manager attributions bulk

> Upsert managers relationships in bulk.

## Behavior

* **Transaction**: If there is at least one manager relationship that trigger
  an error at import, we return you an error and import nothing.
  You have to fix your payload and send it to us again.
  And if the answer is a success, it means that every managers relationships
  you sent us have been upserted.
* **Conflict Rule and upsert**: Be careful, each user can only have one manager
  for a given period. Given new management dates will override conflicting
  dates already present in Qobra.
  Also, if you send a payload with two managers relationship for the same user
  we’ll send you back an error.
* **Limit**: you can’t update more than 200 management relationship at a time.
* **Error behavior**: In case of any error, your manager attributions wont be upserted


## OpenAPI

````yaml put /v1/users/managers/bulk
openapi: 3.0.2
info:
  version: 1.0.0
  title: Qobra API
  description: API documentation for Qobra
servers:
  - url: https://api.qobra.co
    description: API
security: []
paths:
  /v1/users/managers/bulk:
    put:
      tags:
        - public_api
        - v1
        - users
      summary: Upsert manager attributions bulk
      description: Upsert managers relationships in bulk.
      operationId: PUT_/v1/users/managers/bulk
      requestBody:
        description: >-
          The body contains the user data necessary to create a new manager
          relationship in Qobra
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PutManyInputModel_UserManagerPutBodyModel'
            examples:
              manager-bulk-body:
                $ref: >-
                  #/components/examples/PutManyInputModel_UserManagerPutBodyModelExample
        required: true
      responses:
        '200':
          description: Success operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsersManagersBulkPutSuccessModelResponse'
              examples:
                manager-bulk-success:
                  $ref: >-
                    #/components/examples/UsersManagersBulkPutSuccessModelResponseExample
        '400':
          description: ClientError operation
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/UsersManagersBulkPutClientErrorModelResponse
              examples:
                manager-bulk-errors:
                  $ref: >-
                    #/components/examples/UsersManagersBulkPutClientErrorModelResponseExample
      security:
        - api_key: []
components:
  schemas:
    PutManyInputModel_UserManagerPutBodyModel:
      type: object
      properties:
        data:
          title: Data
          type: array
          items:
            $ref: '#/components/schemas/UserManagerPutBodyModel'
      required:
        - data
      title: PutManyInputModel[UserManagerPutBodyModel]
    UsersManagersBulkPutSuccessModelResponse:
      type: object
      properties:
        count:
          description: Upserted manager relationships count
          type: integer
        data:
          description: Array of upserted user-manager relationships
          type: array
          items:
            $ref: '#/components/schemas/UsersManagersBulkSuccessModelResponse'
      required:
        - count
        - data
      title: UsersManagersBulkPutSuccessModelResponse
    UsersManagersBulkPutClientErrorModelResponse:
      type: object
      properties:
        count:
          description: Errors count
          type: integer
        errors:
          description: Array of errors
          type: array
          items:
            $ref: '#/components/schemas/UsersManagersBulkClientErrorModelResponse'
      required:
        - count
        - errors
      title: UsersManagersBulkPutClientErrorModelResponse
    UserManagerPutBodyModel:
      type: object
      properties:
        user:
          title: User
          type: string
          format: email
          description: Unique identifier of the user who is managed
        manager:
          title: Manager
          type: string
          format: email
          description: Unique identifier of the manager
        start_date:
          title: Start Date
          type: string
          description: >-
            Date of the start of the management. Will default to the start of
            the month of your api call
          format: date
        end_date:
          title: End Date
          type: string
          description: >-
            Date of the end of the management. Not providing it will will create
            a relationship with no end date, meaning it never stops until
            overridden
          format: date
      required:
        - user
        - manager
      title: UserManagerPutBodyModel
    UsersManagersBulkSuccessModelResponse:
      type: object
      properties:
        user:
          description: Email of the user
          type: string
          format: email
        manager:
          description: Email of the manager
          type: string
          format: email
        start_date:
          description: Date of the start of the management
          type: string
          format: date
        end_date:
          description: Date of the end of the management
          type: string
          format: date
      required:
        - user
        - manager
        - start_date
      title: UsersManagersBulkSuccessModelResponse
    UsersManagersBulkClientErrorModelResponse:
      type: object
      properties:
        error:
          description: Type of the error
          type: string
        resource:
          description: Related resource in error
          type: string
        description:
          description: Description of the error
          type: string
      required:
        - error
        - resource
        - description
      title: UsersManagersBulkClientErrorModelResponse
  examples:
    PutManyInputModel_UserManagerPutBodyModelExample:
      value:
        data:
          - user: user-1@company.com
            manager: manager-1@company.com
            start_date: 2023-01
            end_date: 2023-10
          - user: user-2@company.com
            manager: manager-2@company.com
          - ...
    UsersManagersBulkPutSuccessModelResponseExample:
      value:
        count: <Upserted manager relationships count>
        data:
          - user: user-1@company.com
            manager: manager-1@company.com
            start_date: 2023-01
            end_date: 2023-10
          - user: user-2@company.com
            manager: manager-2@company.com
            start_date: 2023-03
            end_date: null
          - ...
    UsersManagersBulkPutClientErrorModelResponseExample:
      value:
        count: '4'
        errors:
          - error: NotFoundError
            resource: user
            description: User not found for email user-2@company.com
          - error: NotFoundError
            resource: manager
            description: User not found for email manager-3@company.com
          - error: ParsingError
            resource: <field_name>
            description: >-
              We had issues parsing the <field_name> provided : value
              <value_received>
          - ...
  securitySchemes:
    api_key:
      type: apiKey
      name: X-API-Key
      in: header

````