---
title: "Invoke service"
method: POST
path: "/v1/services/{service_id}/invoke"
tags: ["Services"]
---

# Invoke service

`POST /v1/services/{service_id}/invoke`

## Request

- Base URL: `https://api.sandbase.ai`
- URL: `https://api.sandbase.ai/v1/services/{service_id}/invoke`
- Auth: one of:
  - HTTP bearer
  - API key in header `X-API-Key`

Start a Run. Idempotency-Key is required; the same key and body return the original Run, the same key with a different body returns 409. Only one pending Run is allowed per Service.

## Headers

- `Idempotency-Key` string, required

## Request body

- AgentRunRequest
  - `input` string: Overrides the saved input for this Run. The effective input must be non-empty.
  - `model` string: Overrides the saved model for this Run.
  - `model_provider` ModelProvider: Write-only model credential. Omit it to run with the calling SandBase API key. Never returned.
    - `type` 'sandbase' | 'custom'
    - `base_url` string, uri: Required for custom. HTTPS only, without credentials, query, or fragment. Not allowed for sandbase.
    - `api_key` string: Required for custom. Optional for sandbase, where it defaults to the calling key.

## Response `202`

Run accepted

- AgentRun
  - `id` string, required: Run ID. Treat as opaque.
  - `source_type` 'service' | 'schedule', required
  - `source_id` string, required
  - `source_version` integer, required
  - `agent_id` string, required
  - `agent_version` integer, required
  - `trigger_source` 'manual' | 'scheduled', required
  - `scheduled_at` string, date-time
  - `status` 'pending' | 'succeeded' | 'failed' | 'cancelled' | 'skipped', required: skipped is used when a scheduled tick finds a pending Run.
  - `session_id` string, nullable, required: Session created for this Run; null until the Session exists.
  - `error_code` string: For example session_creation_rejected, execution_failed, schedule_configuration_invalid, concurrency_limit (skipped ticks), or an admission code such as spending_limit_exceeded.
  - `created_at` string, date-time, required
  - `updated_at` string, date-time, required

## Other responses

- `400`: invalid_request (malformed JSON, unknown fields, failed validation, or an unsupported option)
- `401`: unauthorized: missing, malformed, or conflicting API key headers
- `402`: spending_limit_exceeded: API key spending limit or organization balance exhausted
- `403`: insufficient_scope (scoped key) or org_disabled
- `404`: not_found: the resource does not exist in this organization
- `409`: conflict: stale row_version, lifecycle state, or Idempotency-Key reused with a different body
- `429`: concurrency_limit: this resource already has a pending Run
- `503`: authorization_unavailable, admission_unavailable, executor_unavailable, storage_unavailable, or internal_error

---

[API](https://skmtc.dev/sandbase/apis/sandbase-api.md) · [All operations](https://skmtc.dev/sandbase/apis/sandbase-api/llms.txt) · [OpenAPI document](https://skmtc.dev/sandbase/apis/sandbase-api/revisions/d40df2467ba2?raw)
