---
title: "Create credential"
method: POST
path: "/api/credential"
tags: ["credential"]
---

# Create credential

`POST /api/credential`

## Request

- Base URL: `https://opencode.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://opencode.ai/api/credential`
- Auth: none required

Store an integration credential. It becomes the integration's active credential unless activate is false and the integration already has one. Fails with a conflict when the requested ID already exists.

## Request body

- CredentialCreateInput
  - `id` string
  - `integrationID` string, required
  - `label` string
  - `value` union, required
    - CredentialOAuth
      - `type` 'oauth', required
      - `methodID` string, required
      - `refresh` string, required
      - `access` string, required
      - `expires` integer, required
      - `metadata` object
    - CredentialKey
      - `type` 'key', required
      - `key` string, required
      - `metadata` object
    - CredentialExternal
      - `type` 'external', required
      - `methodID` string, required
      - `metadata` object
  - `activate` boolean

## Response `200`

Success

- object
  - `data` CredentialEntry, required
    - `id` string, required
    - `integrationID` string, required
    - `label` string, required
    - `active` boolean, required
    - `value` union, required
      - CredentialOAuth
        - `type` 'oauth', required
        - `methodID` string, required
        - `refresh` string, required
        - `access` string, required
        - `expires` integer, required
        - `metadata` object
      - CredentialKey
        - `type` 'key', required
        - `key` string, required
        - `metadata` object
      - CredentialExternal
        - `type` 'external', required
        - `methodID` string, required
        - `metadata` object

## Other responses

- `400`: InvalidRequestError
- `401`: UnauthorizedError
- `409`: ConflictError

## Changes

> 50 revisions in range; 1 not diffed.

- **2026-10-20** `7d8042ed3561`: 2 warning
  - removed the request property `value/anyOf[#/components/schemas/Credential.Key]/configuration`
  - removed the optional property `data/value/anyOf[#/components/schemas/Credential.Key]/configuration` from the response with the `200` status

[Operation history](https://skmtc.dev/kaaass/apis/opencode/changes/api/credential/post.md)

---

[API](https://skmtc.dev/kaaass/apis/opencode.md) - [All operations](https://skmtc.dev/kaaass/apis/opencode/llms.txt) - [OpenAPI document](https://skmtc.dev/kaaass/apis/opencode/revisions/4e083d954707?raw)
