Batch upsert catalog records

Creates or updates multiple Catalog records at once, so you can send the same records again without creating duplicates.

Each record you send is matched to an existing record by its primary attribute values, then:

  • If it matches an existing record, that record is updated. Only the attributes you include change: attributes you leave out keep their values, and an attribute sent with an empty values array is cleared.
  • If it matches nothing, a new record is created. Existing records that no sent record matches are left unchanged.

When matching, the order of the primary values doesn't matter, and a primary attribute left empty matches only records where it's also empty. If any record in the batch can't be saved, none of them are saved.

PATCH https://incidents.betterstack.com/api/v2/catalog/relations/{relation_id}/records/batch

URL parameters

relation_id
required string

Headers

Authorization
required string
Content-Type
required string

Body parameters

[]
required array
200

Response body

{
  "data": [
    {
      "id": "67",
      "type": "catalog_record",
      "attributes": {
        "attributes": [
          {
            "attribute": {
              "id": 56,
              "name": "Team"
            },
            "values": [
              {
                "type": "String",
                "value": "My Team"
              }
            ]
          },
          {
            "attribute": {
              "id": 57,
              "name": "Team Lead"
            },
            "values": [
              {
                "type": "User",
                "item_id": 123,
                "name": "Alice Smith",
                "email": "alice@example.com"
              }
            ]
          }
        ]
      }
    },
    {
      "id": "68",
      "type": "catalog_record",
      "attributes": {
        "attributes": [
          {
            "attribute": {
              "id": 56,
              "name": "Team"
            },
            "values": [
              {
                "type": "String",
                "value": "Another Team"
              }
            ]
          },
          {
            "attribute": {
              "id": 57,
              "name": "Team Lead"
            },
            "values": [
              {
                "type": "User",
                "item_id": 124,
                "name": "Bob Jones",
                "email": "bob@example.com"
              }
            ]
          }
        ]
      }
    }
  ],
  "meta": {
    "created": [
      "68"
    ],
    "updated": [
      "67"
    ]
  }
}
422

Response body

{
  "errors": {
    "base": [
      "Record 1: Another row in this batch (index 0) has the same primary values."
    ]
  },
  "record_index": 1
}

Example cURL

Example
curl -X "PATCH" "https://incidents.betterstack.com/api/v2/catalog/relations/37/records/batch" \
     -H "Authorization: Bearer $TOKEN" \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'[
  {
    "attributes": [
      {
        "attribute": { "id": "56", "name": "Team" },
        "values": [
          { "type": "String", "value": "My Team" }
        ]
      },
      {
        "attribute": { "id": "57", "name": "Team Lead" },
        "values": [
          { "type": "User", "email": "alice@example.com" }
        ]
      }
    ]
  },
  {
    "attributes": [
      {
        "attribute": { "id": "56", "name": "Team" },
        "values": [
          { "type": "String", "value": "Another Team" }
        ]
      },
      {
        "attribute": { "id": "57", "name": "Team Lead" },
        "values": [
          { "type": "User", "email": "bob@example.com" }
        ]
      }
    ]
  }
]'