---
title: "Create a shared credential for a provider"
method: POST
path: "/v2/directories/{directoryId}/vault/providers/{providerId}/credentials"
tags: ["TokenVaultProviders"]
---

# Create a shared credential for a provider

`POST /v2/directories/{directoryId}/vault/providers/{providerId}/credentials`

## Request

- Base URL: `https://global.api.konghq.com`
- URL: `https://global.api.konghq.com/v2/directories/{directoryId}/vault/providers/{providerId}/credentials`
- Auth: one of:
  - HTTP bearer
  - HTTP bearer
  - HTTP bearer
  - HTTP bearer

Creates a shared credential for a provider. For a static_secret provider, stores
a literal secret value (at most one, a second create returns 409). For a shared
authorization_code provider, mints an OAuth enrollment URL for an
admin to complete once instead of accepting a secret value.

## Path parameters

- `directoryId` string, uuid, required
- `providerId` string, uuid, required

## Request body

- SetVaultProviderCredentialBody: The secret to store. Required and used verbatim for a static_secret provider. Must be omitted for a shared authorization_code provider, where the response instead carries an enrollment_url for an admin to complete OAuth consent.
  - `secret` string: Pre-issued static credential (API key, PAT, etc.). Stored encrypted, never returned in read APIs.
  - `selector` string: CEL expression deciding which callers this credential applies to. Omit to make it the provider's default, which applies to every caller and is considered after all the others.
  - `priority` integer: Order in which this credential is considered, lowest first. Required with a selector, and must be omitted without one.

## Response `201`

Shared credential metadata (never includes the value)

- VaultProviderCredentialShared: The provider's shared secret: a static value, or a shared OAuth enrollment (pending or active).
  - [`VaultProviderCredentialBase`](https://skmtc.dev/kong/apis/konnect-api-go-sdk/revisions/3b071797f6e4/schema?at=%2Fcomponents%2Fschemas%2FVaultProviderCredentialBase)
  - object
    - `credential_type` 'shared', required
    - `selector` string, nullable: CEL expression deciding which callers this credential applies to. Omit to make it the provider's default, which applies to every caller and is considered after all the others.
    - `priority` integer, nullable: Order in which this credential is considered, lowest first. Required with a selector, and must be omitted without one.
    - `status` 'pending' | 'active', required: "pending" until admin enrollment completes; "active" once the secret exists.
    - `enrollment_url` string: URL to complete OAuth consent. Fresh on every get-by-id call; set on create for a shared authorization_code provider. Omitted from list responses.

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `403`: Forbidden
- `404`: Not Found
- `409`: Conflict

## Changes

- **2026-11-16** `a209c8bfa7b7`: 2 info
  - the `credential_type` response property const value `shared` was added for the status `201`
  - removed the `shared` enum value from the `allOf[subschema #2]/credential_type` response property for the response status `201`
- **2026-11-12** `d8bd04cfbaf7`: 1 breaking, 1 warning
  - the `credential_type` response property const value `shared` was removed for the status `201`
  - added the new `shared` enum value to the `allOf[subschema #2]/credential_type` response property for the response status `201`
- **2026-11-05** `ff8439091e5f`: 2 info
  - the `credential_type` response property const value `shared` was added for the status `201`
  - removed the `shared` enum value from the `allOf[subschema #2]/credential_type` response property for the response status `201`
- **2026-11-03** `72599e2b1b09`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/kong/apis/konnect-api-go-sdk/changes/v2/directories/:directoryId/vault/providers/:providerId/credentials/post.md)

---

[API](https://skmtc.dev/kong/apis/konnect-api-go-sdk.md) - [All operations](https://skmtc.dev/kong/apis/konnect-api-go-sdk/llms.txt) - [OpenAPI document](https://skmtc.dev/kong/apis/konnect-api-go-sdk/revisions/3b071797f6e4?raw)
