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

# Create Batch Job

Creates a new job, which runs asynchronously and returns a job ID. The job ID can be used to check the status of the job.

The job contains an array of operations, of the same format as the single changes APIs:

* **Add** - Invites a new member to your Onsi programme.
* **Replace** - Replaces the member's data with new information. An inactive member **will be** re-added to Onsi.
* **Update** - Updates the member's data with new information. Does **not** re-add inactive members.
* **Remove** - Removes the member from your Onsi programme.

#### Unsetting Bank Details

For **Replace** and **Update** operations, you can remove a member's bank details by setting `accountDetails` to `null`.

#### Relevant Error Codes

If there are issues with any of the operations, the API will return a `400` status code with the following error codes:

<Tip>
  If there are issues, Onsi will not process any of the operations in your request, and will not create a job. You will
  need to fix the issues and send a subsequent request.
</Tip>

* [InvalidAddMemberPayload](/api-reference/error-handling#invalidaddmemberpayload)
* [InvalidUpdateMemberPayload](/api-reference/error-handling#invalidupdatememberpayload)
* [InvalidRemoveMemberPayload](/api-reference/error-handling#invalidremovememberpayload)


## OpenAPI

````yaml POST /v1/members/jobs
openapi: 3.0.2
info:
  title: BMO Partner API
  version: v1
servers:
  - url: https://api.onsi.com
    description: Production
  - url: https://api.onsi.dev
    description: Sandbox
security:
  - apiKey: []
paths:
  /v1/members/jobs:
    post:
      tags:
        - members
      operationId: createJob
      parameters:
        - name: x-idempotency-key
          in: header
          description: Unique key to ensure idempotency of the request
          schema:
            type: string
      requestBody:
        description: Body
        content:
          application/json:
            schema:
              type: object
              properties:
                actions:
                  minItems: 1
                  type: array
                  items:
                    anyOf:
                      - description: Add a new member
                        title: Add
                        type: object
                        properties:
                          email:
                            example: jane-smith@onsi.com
                            description: A unique email address for the member
                            type: string
                            format: email
                            pattern: >-
                              ^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$
                          firstName:
                            example: John
                            type: string
                          lastName:
                            example: Smith
                            type: string
                          phone:
                            example: '+447123456789'
                            description: An optional phone number for the member
                            type: string
                          workerId:
                            example: ID_123
                            description: >-
                              Unique ID provided by API consumer, must be unique
                              across all members (active, invited and inactive)
                            type: string
                          tier:
                            example: Gold
                            description: Tier name for the member
                            type: string
                          accountDetails:
                            anyOf:
                              - anyOf:
                                  - title: BankAccountUK
                                    example:
                                      accountHolder: John Smith
                                      sortCode: '123456'
                                      accountNumber: '12345678'
                                    description: A UK bank account
                                    type: object
                                    properties:
                                      accountHolder:
                                        type: string
                                      sortCode:
                                        type: string
                                      accountNumber:
                                        type: string
                                    required:
                                      - accountHolder
                                      - sortCode
                                      - accountNumber
                                    additionalProperties: false
                                  - title: BankAccountEU
                                    example:
                                      accountHolder: John Smith
                                      iban: GB29NWBK60161331926819
                                    description: A EU bank account
                                    type: object
                                    properties:
                                      accountHolder:
                                        type: string
                                      iban:
                                        type: string
                                    required:
                                      - accountHolder
                                      - iban
                                    additionalProperties: false
                                nullable: true
                          enablePayroll:
                            type: boolean
                          dob:
                            example: '1990-01-01'
                            description: Date of birth of the member, must later than 1900
                            type: string
                            pattern: ^\d{4}-\d{2}-\d{2}$
                          gender:
                            anyOf:
                              - description: Gender of the member
                                type: string
                                enum:
                                  - Female
                                  - Male
                                  - NonBinary
                                nullable: true
                          type:
                            type: string
                            enum:
                              - Add
                        required:
                          - email
                          - firstName
                          - lastName
                          - tier
                          - type
                        additionalProperties: false
                      - description: Replace an existing member
                        title: Replace
                        type: object
                        properties:
                          email:
                            example: jane-smith@onsi.com
                            description: A unique email address for the member
                            type: string
                            format: email
                            pattern: >-
                              ^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$
                          firstName:
                            example: John
                            type: string
                          lastName:
                            example: Smith
                            type: string
                          phone:
                            example: '+447123456789'
                            description: An optional phone number for the member
                            type: string
                          workerId:
                            example: ID_123
                            description: >-
                              Unique ID provided by API consumer, must be unique
                              across all members (active, invited and inactive)
                            type: string
                          tier:
                            example: Gold
                            description: Tier name for the member
                            type: string
                          accountDetails:
                            anyOf:
                              - anyOf:
                                  - title: BankAccountUK
                                    example:
                                      accountHolder: John Smith
                                      sortCode: '123456'
                                      accountNumber: '12345678'
                                    description: A UK bank account
                                    type: object
                                    properties:
                                      accountHolder:
                                        type: string
                                      sortCode:
                                        type: string
                                      accountNumber:
                                        type: string
                                    required:
                                      - accountHolder
                                      - sortCode
                                      - accountNumber
                                    additionalProperties: false
                                  - title: BankAccountEU
                                    example:
                                      accountHolder: John Smith
                                      iban: GB29NWBK60161331926819
                                    description: A EU bank account
                                    type: object
                                    properties:
                                      accountHolder:
                                        type: string
                                      iban:
                                        type: string
                                    required:
                                      - accountHolder
                                      - iban
                                    additionalProperties: false
                                nullable: true
                          enablePayroll:
                            type: boolean
                          dob:
                            example: '1990-01-01'
                            description: Date of birth of the member, must later than 1900
                            type: string
                            pattern: ^\d{4}-\d{2}-\d{2}$
                          gender:
                            anyOf:
                              - description: Gender of the member
                                type: string
                                enum:
                                  - Female
                                  - Male
                                  - NonBinary
                                nullable: true
                          type:
                            type: string
                            enum:
                              - Replace
                          memberId:
                            example: mem_<id>
                            description: >-
                              The unique identifier for a Member, prefixed with
                              mem_
                            type: string
                        required:
                          - email
                          - firstName
                          - lastName
                          - tier
                          - type
                          - memberId
                        additionalProperties: false
                      - description: Update an existing member
                        title: Update
                        type: object
                        properties:
                          email:
                            description: >-
                              This can only be changed if member status is
                              `invited`
                            type: string
                            format: email
                            pattern: >-
                              ^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$
                          firstName:
                            description: First name of the member
                            type: string
                          lastName:
                            description: Last name of the member
                            type: string
                          phone:
                            description: Phone number
                            type: string
                          workerId:
                            anyOf:
                              - example: ID_123
                                description: >-
                                  Unique ID provided by API consumer, must be
                                  unique across all members (active, invited and
                                  inactive)
                                type: string
                                nullable: true
                          tier:
                            description: Tier name
                            type: string
                          accountDetails:
                            anyOf:
                              - anyOf:
                                  - title: BankAccountUK
                                    example:
                                      accountHolder: John Smith
                                      sortCode: '123456'
                                      accountNumber: '12345678'
                                    description: A UK bank account
                                    type: object
                                    properties:
                                      accountHolder:
                                        type: string
                                      sortCode:
                                        type: string
                                      accountNumber:
                                        type: string
                                    required:
                                      - accountHolder
                                      - sortCode
                                      - accountNumber
                                    additionalProperties: false
                                  - title: BankAccountEU
                                    example:
                                      accountHolder: John Smith
                                      iban: GB29NWBK60161331926819
                                    description: A EU bank account
                                    type: object
                                    properties:
                                      accountHolder:
                                        type: string
                                      iban:
                                        type: string
                                    required:
                                      - accountHolder
                                      - iban
                                    additionalProperties: false
                                nullable: true
                          enablePayroll:
                            type: boolean
                          dob:
                            example: '1990-01-01'
                            description: Date of birth of the member, must later than 1900
                            type: string
                            pattern: ^\d{4}-\d{2}-\d{2}$
                          gender:
                            anyOf:
                              - description: Gender of the member
                                type: string
                                enum:
                                  - Female
                                  - Male
                                  - NonBinary
                                nullable: true
                          type:
                            type: string
                            enum:
                              - Update
                          memberId:
                            example: mem_<id>
                            description: >-
                              The unique identifier for a Member, prefixed with
                              mem_
                            type: string
                        required:
                          - type
                          - memberId
                        additionalProperties: false
                      - description: Offboard a member
                        title: Offboard
                        type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - Offboard
                          memberId:
                            example: mem_<id>
                            description: >-
                              The unique identifier for a Member, prefixed with
                              mem_
                            type: string
                        required:
                          - type
                          - memberId
                        additionalProperties: false
              required:
                - actions
              additionalProperties: false
      responses:
        '202':
          description: '202'
          content:
            application/json:
              schema:
                type: object
                properties:
                  jobId:
                    example: maj_cltd2zp7100096tmbamb9c46o
                    type: string
                required:
                  - jobId
                additionalProperties: false
components:
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key

````