---
title: "Add a new stub to the store"
method: POST
path: "/stubs"
tags: ["stubs"]
---

# Add a new stub to the store

`POST /stubs`

Creates a new stub or multiple stubs and adds them to the storage

## Request body

- union
  - Stub[]
    - `id` string, uuid
    - `service` string, required
    - `method` string, required
    - `priority` integer — Priority of the stub. Higher priority stubs are matched first.
    - `used` boolean — Response-only — whether the stub has matched at least once. Ignored on input.
    - `headers` StubHeaders
      - `equals` object
      - `contains` object
      - `matches` object
      - `anyOf` StubHeadersAnyOfElement[] — Alternative header matchers (OR logic)
        - `equals` object
        - `contains` object
        - `matches` object
    - `input` StubInput, required
      - `ignoreArrayOrder` boolean
      - `equals` object
      - `contains` object
      - `matches` object
      - `anyOf` StubInputAnyOfElement[] — Alternative input matchers (OR logic)
        - `ignoreArrayOrder` boolean
        - `equals` object
        - `contains` object
        - `matches` object
    - `inputs` StubInput[] — Inputs to match against. If multiple inputs are provided, the stub will be matched if any of the inputs match.
      - `ignoreArrayOrder` boolean
      - `equals` object
      - `contains` object
      - `matches` object
      - `anyOf` StubInputAnyOfElement[] — Alternative input matchers (OR logic)
        - `ignoreArrayOrder` boolean
        - `equals` object
        - `contains` object
        - `matches` object
    - `output` StubOutput, required
      - `data` unknown
      - `stream` unknown[]
        - unknown
      - `headers` object
      - `error` string
      - `code` integer
      - `details` object[] — gRPC status details packed into google.protobuf.Any (each item must contain type URL in `type`)
        - `type` string, required — Full Any type URL (for example, type.googleapis.com/google.rpc.ErrorInfo)
      - `delay` string — Delay before sending the response
    - `options` StubOptions — Optional behavior settings for a stub
      - `times` integer — Max number of matches; 0 = unlimited
    - `effects` StubEffect[] — Side effects applied after successful stub match
      - `action` 'upsert' | 'delete', required
      - `id` string — Stub UUID for delete action
      - `stub` object — Stub payload for upsert action
    - `source` string — Source of the stub (file, rest, mcp, proxy)
  - Stub
    - `id` string, uuid
    - `service` string, required
    - `method` string, required
    - `priority` integer — Priority of the stub. Higher priority stubs are matched first.
    - `used` boolean — Response-only — whether the stub has matched at least once. Ignored on input.
    - `headers` StubHeaders
      - `equals` object
      - `contains` object
      - `matches` object
      - `anyOf` StubHeadersAnyOfElement[] — Alternative header matchers (OR logic)
        - `equals` object
        - `contains` object
        - `matches` object
    - `input` StubInput, required
      - `ignoreArrayOrder` boolean
      - `equals` object
      - `contains` object
      - `matches` object
      - `anyOf` StubInputAnyOfElement[] — Alternative input matchers (OR logic)
        - `ignoreArrayOrder` boolean
        - `equals` object
        - `contains` object
        - `matches` object
    - `inputs` StubInput[] — Inputs to match against. If multiple inputs are provided, the stub will be matched if any of the inputs match.
      - `ignoreArrayOrder` boolean
      - `equals` object
      - `contains` object
      - `matches` object
      - `anyOf` StubInputAnyOfElement[] — Alternative input matchers (OR logic)
        - `ignoreArrayOrder` boolean
        - `equals` object
        - `contains` object
        - `matches` object
    - `output` StubOutput, required
      - `data` unknown
      - `stream` unknown[]
        - unknown
      - `headers` object
      - `error` string
      - `code` integer
      - `details` object[] — gRPC status details packed into google.protobuf.Any (each item must contain type URL in `type`)
        - `type` string, required — Full Any type URL (for example, type.googleapis.com/google.rpc.ErrorInfo)
      - `delay` string — Delay before sending the response
    - `options` StubOptions — Optional behavior settings for a stub
      - `times` integer — Max number of matches; 0 = unlimited
    - `effects` StubEffect[] — Side effects applied after successful stub match
      - `action` 'upsert' | 'delete', required
      - `id` string — Stub UUID for delete action
      - `stub` object — Stub payload for upsert action
    - `source` string — Source of the stub (file, rest, mcp, proxy)

## Response `200`

Successful operation

- ID[]

## Other responses

- `400` — Invalid stub data
- `422` — Validation error
- `500` — Internal Server Error

## Changes

- **2026-07-20** `e2b32002bad4` — 2 info
  - added the new optional request property `oneOf[#/components/schemas/StubList]/items/used`
  - added the new optional request property `oneOf[#/components/schemas/Stub]/used`
- **2026-06-13** `4003b62da452` — 4 breaking
  - the `oneOf[#/components/schemas/StubList]/items/output/data` request property type changed from `object` to no type
  - the `oneOf[#/components/schemas/StubList]/items/output/stream/items/` request property type changed from `object` to no type
  - the `oneOf[#/components/schemas/Stub]/output/data` request property type changed from `object` to no type
  - the `oneOf[#/components/schemas/Stub]/output/stream/items/` request property type changed from `object` to no type
- **2026-04-22** `9baafb13a873` — 8 info
  - added the new optional request property `oneOf[#/components/schemas/StubList]/items/effects`
  - added the new optional request property `oneOf[#/components/schemas/StubList]/items/headers/anyOf`
  - added the new optional request property `oneOf[#/components/schemas/StubList]/items/input/anyOf`
  - added the new optional request property `oneOf[#/components/schemas/StubList]/items/inputs/items/anyOf`
  - …4 more
- **2026-03-07** `95a6a42172d8` — 2 info
  - added the new optional request property `oneOf[#/components/schemas/StubList]/items/output/details`
  - added the new optional request property `oneOf[#/components/schemas/Stub]/output/details`
- …earlier changes not shown

[Full history](https://skmtc.dev/bavix/apis/gripmock-api-schema/changes/stubs/post.md)

---

[API](https://skmtc.dev/bavix/apis/gripmock-api-schema.md) · [All operations](https://skmtc.dev/bavix/apis/gripmock-api-schema/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/bavix/gripmock-api-schema/revisions/e2b32002bad4/schema)
