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

# Validate a batch of catalog writes together, without writing anything

> Runs every item as its own write would run with `?dry_run=true`, but all of them in one database transaction that is always rolled back, so the batch is checked as a whole: an item may name a resource another item of the batch creates (a product's usage price naming a new meter by `meter_external_id`), and every check, uniqueness rule and guard runs against what the earlier items would have written. Items run in dependency order (meters, products, product groups, discounts) and are answered in the order of the request. Without `id` an item runs as the keyed upsert of its kind (`POST /v1/products`, `POST /v1/meters`) with the same body; with `id` it runs as that resource's `PATCH` with `PATCH`'s rules, which is meant for a migrator adopting an existing resource (giving it an `external_id`). Requires `products:write` and the write scope of every kind in the batch (`meters:write` for meters). Nothing is written and nothing is triggered. A batch that passes can still fail when it is applied, if the catalog changes in between; validate it again right before applying it.



## OpenAPI

````yaml post /v1/catalog/validate
openapi: 3.0.0
info:
  title: Creem API
  description: >-
    Creem is an all-in-one platform for managing subscriptions and recurring
    revenue, tailored specifically for today's SaaS companies. It enables you to
    boost revenue, enhance customer retention, and scale your operations
    seamlessly.
  version: v1
  contact:
    name: Creem Support
    url: https://creem.io
    email: support@creem.io
  license:
    name: Commercial
    url: https://creem.io/terms
  termsOfService: https://creem.io/terms
servers:
  - url: https://api.creem.io
    description: Production — live API for processing real transactions and data.
    x-speakeasy-server-id: prod
  - url: https://test-api.creem.io
    description: Test — sandbox API for development and testing with no real charges.
    x-speakeasy-server-id: test
security: []
tags: []
externalDocs:
  description: Creem Documentation
  url: https://docs.creem.io
paths:
  /v1/catalog/validate:
    post:
      tags:
        - Catalog
      summary: Validate a batch of catalog writes together, without writing anything.
      description: >-
        Runs every item as its own write would run with `?dry_run=true`, but all
        of them in one database transaction that is always rolled back, so the
        batch is checked as a whole: an item may name a resource another item of
        the batch creates (a product's usage price naming a new meter by
        `meter_external_id`), and every check, uniqueness rule and guard runs
        against what the earlier items would have written. Items run in
        dependency order (meters, products, product groups, discounts) and are
        answered in the order of the request. Without `id` an item runs as the
        keyed upsert of its kind (`POST /v1/products`, `POST /v1/meters`) with
        the same body; with `id` it runs as that resource's `PATCH` with
        `PATCH`'s rules, which is meant for a migrator adopting an existing
        resource (giving it an `external_id`). Requires `products:write` and the
        write scope of every kind in the batch (`meters:write` for meters).
        Nothing is written and nothing is triggered. A batch that passes can
        still fail when it is applied, if the catalog changes in between;
        validate it again right before applying it.
      operationId: validateCatalog
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CatalogValidateRequestDto'
      responses:
        '200':
          description: Every item passes. One answer per item, in the order of the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CatalogValidationResponseDto'
        '400':
          description: >-
            Bad request, and nothing was checked. Besides validation errors of
            the request itself: `validate_batch_too_large`: the batch holds more
            than 100 items (`details.max_items`, `details.items`); split it, for
            example one dependency layer per call. `dry_run_not_supported`: an
            item's `kind` can't be validated yet (`details.kind`:
            `product_group` or `discount`), or the request sent `dry_run`
            (validate never writes). `validate_batch_timeout`: the batch
            couldn't be checked within 15 seconds (`details.timeout_ms`),
            because its items are large or one waited on a resource another
            request was writing; nothing was written. Split it into smaller
            batches; sending the same batch again takes as long. An item's own
            validation error is not a `400` of the call: it is that item's
            answer in a `422`.
        '401':
          description: Unauthorized - Invalid or missing API key
        '403':
          description: >-
            Forbidden: the API key or access token lacks `products:write` or the
            write scope of a kind in the batch (`meters:write`,
            `discounts:write`). Nothing was checked.
        '404':
          description: Not Found - Resource does not exist
        '422':
          description: >-
            At least one item fails. The same answer as `200`, with `valid`
            `false`: each failing item carries its endpoint’s status and error
            body. Nothing was written.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CatalogValidationResponseDto'
      security:
        - ApiKey: []
components:
  schemas:
    CatalogValidateRequestDto:
      type: object
      properties:
        items:
          description: >-
            The writes to check together, at most 100. They run in dependency
            order (meters, products, product groups, discounts), so an item may
            name a resource another item of the batch creates (a usage price's
            `meter_external_id`). A larger batch answers `400`
            `validate_batch_too_large` and nothing is checked.
          type: array
          items:
            $ref: '#/components/schemas/CatalogValidateItemRequestDto'
      required:
        - items
    CatalogValidationResponseDto:
      type: object
      properties:
        object:
          type: string
          description: Always `catalog_validation`.
        valid:
          type: boolean
          description: >-
            Whether every item passes. The status is `200` when it is true and
            `422` otherwise.
        items:
          description: One entry per item, in the order of the request.
          type: array
          items:
            $ref: '#/components/schemas/CatalogValidationItemResponseDto'
      required:
        - object
        - valid
        - items
    CatalogValidateItemRequestDto:
      type: object
      properties:
        kind:
          type: string
          enum:
            - meter
            - product
            - product_group
            - discount
          description: >-
            The kind of resource the item writes. `meter` and `product` can be
            validated; `product_group` and `discount` answer `400`
            `dry_run_not_supported` until their writes support a dry run.
        id:
          type: string
          description: >-
            For a migrator adopting an existing resource only: the id of the
            resource the item updates. With `id` the item runs as that
            resource’s `PATCH` (`PATCH /v1/products/{id}`, `PATCH
            /v1/meters/{id}`) with `PATCH`’s rules, for example to give a
            product without an `external_id` its key. Without `id` the item runs
            as the keyed upsert of its kind (`POST /v1/products`, `POST
            /v1/meters`).
        body:
          type: object
          additionalProperties: true
          description: >-
            The request body of the write: without `id` the body of the kind’s
            create or upsert (`POST /v1/products`, `POST /v1/meters`), with `id`
            the body of its `PATCH`. It is validated as that endpoint validates
            it.
      required:
        - kind
        - body
    CatalogValidationItemResponseDto:
      type: object
      properties:
        kind:
          type: string
          description: >-
            The item’s `kind`: `meter`, `product`, `product_group` or
            `discount`.
        id:
          type: string
          nullable: true
          description: The item’s `id`, or null for an upsert item.
        valid:
          type: boolean
          description: Whether the item’s write would succeed.
        status:
          type: number
          description: >-
            The status the item’s own endpoint answers for this write: `200` or
            `201` when it passes, its error status (`400`, `404`, `409`, `412`,
            `422`, …) when it fails.
        response:
          type: object
          additionalProperties: true
          nullable: true
          description: >-
            When the item passes: what its endpoint answers with
            `?dry_run=true`, the resource with `write_result` (`dry_run`
            `true`), for a product the `POST` or `PATCH /v1/products` response,
            for a meter the `POST` or `PATCH /v1/meters` response. Ids of
            resources the batch would create are never stored. Null when the
            item fails.
        error:
          type: object
          additionalProperties: true
          nullable: true
          description: >-
            When the item fails: the error body its endpoint answers, in that
            endpoint’s envelope, with its stable `code` (for example
            `external_id_taken`, `usage_price_in_use`, `meter_name_taken`). Null
            when the item passes.
      required:
        - kind
        - id
        - valid
        - status
        - response
        - error
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        API key for authentication. You can find your API key in the Creem
        dashboard under Settings > API Keys.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.