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

# Upsert Documents in Bulk

> Update existing documents or create new ones in bulk. Documents with a matching `id` are updated; documents without a matching `id` are created. Each document is limited to 2 MB.



## OpenAPI

````yaml /openapi/framework/appdb.yaml put /domo/datastores/v2/collections/{collectionName}/documents/bulk
openapi: 3.0.0
info:
  title: Domo AppDB API
  version: v1
  description: >
    AppDB API for storing arbitrary JSON documents similar to a NoSQL database.
    This enables storing state within your DomoApp

    with optional syncing to Domo DataSets.


    Three layers provide data storage:

    - **Datastores**: Analogous to a database. A CustomApp has a single
    datastore created automatically.

    - **Collections**: Analogous to a collection in NoSQL or table in relational
    databases.

    - **Documents**: Analogous to documents in NoSQL or table rows in relational
    databases.
servers:
  - url: https://{instance}.domo.com
    description: Domo Instance
    variables:
      instance:
        default: example
        description: Your Domo instance name
security: []
paths:
  /domo/datastores/v2/collections/{collectionName}/documents/bulk:
    put:
      tags:
        - AppDB API
      summary: Upsert Documents in Bulk
      description: >-
        Update existing documents or create new ones in bulk. Documents with a
        matching `id` are updated; documents without a matching `id` are
        created. Each document is limited to 2 MB.
      parameters:
        - $ref: '#/components/parameters/CollectionName'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                  content:
                    type: object
                    additionalProperties: true
            example:
              - id: 402778f6-bc8d-4aa5-a581-e08e3fc98c05
                content:
                  name: Harry Potter
                  house: Gryffindor
                  wand:
                    wood: holly
                    core: phoenix feather
                    length: 11
                  courses:
                    - Defense Against the Dark Arts
                    - Potions
                    - Transfiguration
                  prefect: false
                  enrolledOn: '1991-09-01'
                  lastDetention: '1994-06-08T20:00:00Z'
              - id: dd363c89-60d2-4f70-89cb-c3c175be625b
                content:
                  name: Hermione Granger
                  house: Gryffindor
                  wand:
                    wood: vine
                    core: dragon heartstring
                    length: 10.75
                  courses:
                    - Potions
                    - Transfiguration
                    - Arithmancy
                    - Care of Magical Creatures
                  prefect: true
                  enrolledOn: '1991-09-01'
                  lastDetention: '1995-10-15T15:30:00Z'
              - content:
                  name: Ron Weasley
                  house: Gryffindor
                  wand:
                    wood: willow
                    core: unicorn hair
                    length: 14
                  courses:
                    - Defense Against the Dark Arts
                    - Potions
                    - Divination
      responses:
        '200':
          description: Bulk upsert result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BulkUpsertResponse'
              example:
                Updated: 2
                Created: 1
        '400':
          description: >-
            Bad request. One or more of the document IDs in the request do not
            exist in the collection.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                message: >-
                  The following document IDs do not exist:
                  18d29306-934f-4869-9c16-1843eaf9df42
                status: 400
                statusReason: Bad Request
                toe: 4LSUUFVGRL-4BDIB-2THSU
        '403':
          description: >-
            Forbidden. The user is missing a required permission —
            UPDATE_CONTENT when updating existing documents, or CREATE_CONTENT
            when inserting new ones.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                missingUpdatePermission:
                  summary: Missing UPDATE_CONTENT permission
                  value:
                    message: >-
                      User does not have permission to update documents in this
                      collection.
                    status: 403
                    statusReason: Forbidden
                    toe: 2Z8PMHEI9H-0OJ88-NV4Y1
                missingCreatePermission:
                  summary: Missing CREATE_CONTENT permission
                  value:
                    message: >-
                      User does not have permission to create documents in this
                      collection.
                    status: 403
                    statusReason: Forbidden
                    toe: Y3CKVRLQVS-Z5JZT-PVA6W
        '404':
          description: >-
            Collection not found. Verify the collection name is correct (it is
            case-sensitive) and that the collection has been created or
            correctly wired in this app's datastore.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: 404
                statusReason: >-
                  DA0088: Collection 'students' was not found in datastore
                  875557bc-679d-40a0-ac7e-9e8251dc3fde - it may not exist on
                  this instance or may not be accessible
                toe: DJGTVPTJZL-6MOPE-AD42K
      x-codeSamples:
        - lang: JavaScript
          label: domo.js
          source: >-
            const collectionName = 'Students';


            domo.put(`/domo/datastores/v2/collections/${collectionName}/documents/bulk`,
            [
              {
                id: '402778f6-bc8d-4aa5-a581-e08e3fc98c05',
                content: {
                  name: 'Harry Potter',
                  house: 'Gryffindor',
                  wand: { wood: 'holly', core: 'phoenix feather', length: 11 },
                  courses: ['Defense Against the Dark Arts', 'Potions', 'Transfiguration'],
                  prefect: false
                }
              },
              {
                id: 'dd363c89-60d2-4f70-89cb-c3c175be625b',
                content: {
                  name: 'Hermione Granger',
                  house: 'Gryffindor',
                  wand: { wood: 'vine', core: 'dragon heartstring', length: 10.75 },
                  courses: ['Potions', 'Transfiguration', 'Arithmancy', 'Care of Magical Creatures'],
                  prefect: true
                }
              },
              {
                content: {
                  name: 'Ron Weasley',
                  house: 'Gryffindor',
                  wand: { wood: 'willow', core: 'unicorn hair', length: 14 },
                  courses: ['Defense Against the Dark Arts', 'Potions', 'Divination']
                }
              }
            ]).then(result => console.log(result));
        - lang: JavaScript
          label: domo.js v6
          source: >-
            // domo.js v6

            const collectionName = 'Students';


            // bulkUpsert auto-wraps content — pass content fields directly.

            // Documents with a matching id are updated; those without are
            created.

            const result = await domo.appdb.bulkUpsert(collectionName, [
              {
                id: '402778f6-bc8d-4aa5-a581-e08e3fc98c05',
                name: 'Harry Potter',
                house: 'Gryffindor',
                wand: { wood: 'holly', core: 'phoenix feather', length: 11 },
                courses: ['Defense Against the Dark Arts', 'Potions', 'Transfiguration'],
                prefect: false
              },
              {
                id: 'dd363c89-60d2-4f70-89cb-c3c175be625b',
                name: 'Hermione Granger',
                house: 'Gryffindor',
                wand: { wood: 'vine', core: 'dragon heartstring', length: 10.75 },
                courses: ['Potions', 'Transfiguration', 'Arithmancy', 'Care of Magical Creatures'],
                prefect: true
              },
              {
                name: 'Ron Weasley',
                house: 'Gryffindor',
                wand: { wood: 'willow', core: 'unicorn hair', length: 14 },
                courses: ['Defense Against the Dark Arts', 'Potions', 'Divination']
              }
            ]);

            console.log(result);
        - lang: cURL
          label: cURL
          source: |-
            # This API is only available inside a Domo app.
            # Use the JavaScript (domo.js) tab for the correct usage.
        - lang: Python
          label: Python
          source: |-
            # This API is only available inside a Domo app.
            # Use the JavaScript (domo.js) tab for the correct usage.
        - lang: PHP
          label: PHP
          source: |-
            // This API is only available inside a Domo app.
            // Use the JavaScript (domo.js) tab for the correct usage.
        - lang: Go
          label: Go
          source: |-
            // This API is only available inside a Domo app.
            // Use the JavaScript (domo.js) tab for the correct usage.
        - lang: Java
          label: Java
          source: |-
            // This API is only available inside a Domo app.
            // Use the JavaScript (domo.js) tab for the correct usage.
        - lang: Ruby
          label: Ruby
          source: |-
            # This API is only available inside a Domo app.
            # Use the JavaScript (domo.js) tab for the correct usage.
components:
  parameters:
    CollectionName:
      name: collectionName
      in: path
      required: true
      description: The name given to the collection in the manifest. Case-sensitive.
      schema:
        type: string
  schemas:
    BulkUpsertResponse:
      type: object
      properties:
        Updated:
          type: integer
        Created:
          type: integer
      example:
        Updated: 1
        Created: 1
    ErrorResponse:
      type: object
      properties:
        message:
          type: string
          description: >-
            A plain-English explanation of the error. Present on some errors but
            not all.
        status:
          type: integer
          description: The HTTP error code
        statusReason:
          type: string
          description: >-
            A human-readable error message, sometimes including nested error
            detail
        toe:
          type: string
          description: >-
            Thread of Execution; a unique identifier that Support can use to
            find more info about your problem
      example:
        status: 404
        statusReason: 'DA0088: Invalid collection name: Students'
        toe: FTYRJMBLKD-5HB2Z-H6W8A

````