> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.usepassport.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.usepassport.ai/_mcp/server.

# Replace an endpoint's secret bindings

PUT https://api.usepassport.ai/public/v1/endpoints/{endpointId}/secret-bindings
Content-Type: application/json

Full-replace: the provided list becomes the endpoint's complete set of secret slots. Each `secretReferenceId` (when present) must belong to the endpoint's namespace.


Reference: https://docs.usepassport.ai/api-reference/secret-bindings/replace-secret-bindings

## Authentication

- `Authorization` header (bearer token, required) — WorkOS API key (Authorization: Bearer sk_...). Scope comes from the key's permissions: a key carrying `passport:admin` has admin scope (full catalog CRUD), any other key has member scope (reads + access requests). Organization-owned keys are admin by ownership and carry no associated user; keys minted for a user carry theirs, which is what access requests and `createdBy` are attributed to.

## Request

### Path parameters

- `endpointId` (string, required)

### Body (application/json)

This endpoint expects a SecretBindingsReplace.

- `SecretBindingsReplace`
  - Wrapped: Wrapped
  - Bare array: list of SecretBinding

## Response

### 200

OK

- `data` (list of SecretBinding, required)

## Errors

### 400 Bad Request Error

The secret-bindings body is invalid.

- `error` (ErrorError, required)

### 401 Unauthorized Error

Missing or invalid API key. Unlike every other response, this one carries no `RateLimit-*` headers: the request is rejected before a key is resolved, so there is no per-key window to report. Rejection happens at the gateway, which renders this same schema (and negotiates `application/problem+json` identically).

- `error` (ErrorError, required)

### 403 Forbidden Error

Authenticated but lacking required role (e.g. member key on a catalog mutation).

- `error` (ErrorError, required)

### 404 Not Found Error

Resource endpoint not found.

- `error` (ErrorError, required)

### 429 Too Many Requests Error

Rate limit exceeded.

- `error` (ErrorError, required)

### 500 Internal Server Error

Unexpected server error.

- `error` (ErrorError, required)

### 503 Service Unavailable Error

Temporary unavailability (auth dependency down, encryption-config resolution failure, or discovery document unloadable).

- `error` (ErrorError, required)

## Types

### Wrapped

- `bindings` (list of SecretBinding, required)

### SecretBinding

- `label` (string, required) — Display name of the slot, for example `Authorization`. It identifies the slot within its endpoint and has no effect on where a secret may be used, which is decided only by `allowedLocations`.
- `secretReferenceId` (string, optional, nullable) — null for an unmapped slot.
- `allowedLocations` (SecretBindingAllowedLocations, optional, nullable) — Where the secret reference may be substituted in a request, as a JSON object (never a string). `{"v": 1, "headers": ["x-api-key"]}` means the proxy substitutes it only in those request headers, never in the URI, query string or body. `null` means anywhere. Admin-set. `v` must be 1 and `headers` holds 1 to 16 header names; anything else returns `400`. Header names are trimmed, lower-cased, de-duplicated and sorted on write, so the response can differ from the request. Responses leave the field out when a slot has no rule. When a slot is saved without a rule, the recommended rule for a known LLM host (for example `api.anthropic.com` or `api.openai.com`) is filled in, so a response can contain a rule you did not send; send `null` to allow anywhere.

### ErrorError

- `code` (enum, required) — The machine-readable failure reason. Treat a value not listed here as a generic failure of the class implied by the HTTP status, and do not assume retry behaviour for it — new codes may be added.
  - Allowed values: `VALIDATION_ERROR`, `MALFORMED_JSON`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `CONFLICT`, `UNPROCESSABLE_ENTITY`, `PAYLOAD_TOO_LARGE`, `RATE_LIMITED`, `INTERNAL_ERROR`, `SERVICE_UNAVAILABLE`
- `message` (string, required)
- `details` (list of FieldError, optional)

### SecretBindingAllowedLocations

Where the secret reference may be substituted in a request, as a JSON object (never a string). `{"v": 1, "headers": ["x-api-key"]}` means the proxy substitutes it only in those request headers, never in the URI, query string or body. `null` means anywhere. Admin-set. `v` must be 1 and `headers` holds 1 to 16 header names; anything else returns `400`. Header names are trimmed, lower-cased, de-duplicated and sorted on write, so the response can differ from the request. Responses leave the field out when a slot has no rule. When a slot is saved without a rule, the recommended rule for a known LLM host (for example `api.anthropic.com` or `api.openai.com`) is filled in, so a response can contain a rule you did not send; send `null` to allow anywhere.

- `v` (enum, required)
  - Allowed values: `1`
- `headers` (list of string, required)

### FieldError

- `field` (string, optional)
- `message` (string, optional)

## Examples

### default

**Request**

```json
{
  "bindings": [
    {
      "label": "Authorization",
      "secretReferenceId": "5c6d7e8f-9a0b-1c2d-3e4f-5a6b7c8d9e0f"
    },
    {
      "label": "X-Idempotency-Key",
      "secretReferenceId": null
    }
  ]
}
```

**Response**

```json
{
  "data": [
    {
      "label": "API_KEY",
      "secretReferenceId": "b2c3d4e5-2222-3333-4444-555566667777"
    }
  ]
}
```

**SDK Code**

```python default
import requests

url = "https://api.usepassport.ai/public/v1/endpoints/endpointId/secret-bindings"

payload = { "bindings": [
        {
            "label": "Authorization",
            "secretReferenceId": "5c6d7e8f-9a0b-1c2d-3e4f-5a6b7c8d9e0f"
        },
        {
            "label": "X-Idempotency-Key",
            "secretReferenceId": None
        }
    ] }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.json())
```

```javascript default
const url = 'https://api.usepassport.ai/public/v1/endpoints/endpointId/secret-bindings';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"bindings":[{"label":"Authorization","secretReferenceId":"5c6d7e8f-9a0b-1c2d-3e4f-5a6b7c8d9e0f"},{"label":"X-Idempotency-Key","secretReferenceId":null}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go default
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.usepassport.ai/public/v1/endpoints/endpointId/secret-bindings"

	payload := strings.NewReader("{\n  \"bindings\": [\n    {\n      \"label\": \"Authorization\",\n      \"secretReferenceId\": \"5c6d7e8f-9a0b-1c2d-3e4f-5a6b7c8d9e0f\"\n    },\n    {\n      \"label\": \"X-Idempotency-Key\",\n      \"secretReferenceId\": null\n    }\n  ]\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby default
require 'uri'
require 'net/http'

url = URI("https://api.usepassport.ai/public/v1/endpoints/endpointId/secret-bindings")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"bindings\": [\n    {\n      \"label\": \"Authorization\",\n      \"secretReferenceId\": \"5c6d7e8f-9a0b-1c2d-3e4f-5a6b7c8d9e0f\"\n    },\n    {\n      \"label\": \"X-Idempotency-Key\",\n      \"secretReferenceId\": null\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java default
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://api.usepassport.ai/public/v1/endpoints/endpointId/secret-bindings")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"bindings\": [\n    {\n      \"label\": \"Authorization\",\n      \"secretReferenceId\": \"5c6d7e8f-9a0b-1c2d-3e4f-5a6b7c8d9e0f\"\n    },\n    {\n      \"label\": \"X-Idempotency-Key\",\n      \"secretReferenceId\": null\n    }\n  ]\n}")
  .asString();
```

```php default
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.usepassport.ai/public/v1/endpoints/endpointId/secret-bindings', [
  'body' => '{
  "bindings": [
    {
      "label": "Authorization",
      "secretReferenceId": "5c6d7e8f-9a0b-1c2d-3e4f-5a6b7c8d9e0f"
    },
    {
      "label": "X-Idempotency-Key",
      "secretReferenceId": null
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp default
using RestSharp;

var client = new RestClient("https://api.usepassport.ai/public/v1/endpoints/endpointId/secret-bindings");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"bindings\": [\n    {\n      \"label\": \"Authorization\",\n      \"secretReferenceId\": \"5c6d7e8f-9a0b-1c2d-3e4f-5a6b7c8d9e0f\"\n    },\n    {\n      \"label\": \"X-Idempotency-Key\",\n      \"secretReferenceId\": null\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift default
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["bindings": [
    [
      "label": "Authorization",
      "secretReferenceId": "5c6d7e8f-9a0b-1c2d-3e4f-5a6b7c8d9e0f"
    ],
    [
      "label": "X-Idempotency-Key",
      "secretReferenceId": 
    ]
  ]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.usepassport.ai/public/v1/endpoints/endpointId/secret-bindings")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### A binding with a rule

**Request**

```json
{
  "bindings": [
    {
      "allowedLocations": {
        "headers": [
          "authorization"
        ],
        "v": 1
      },
      "label": "Authorization",
      "secretReferenceId": "5c6d7e8f-9a0b-1c2d-3e4f-5a6b7c8d9e0f"
    }
  ]
}
```

**Response**

```json
{
  "data": [
    {
      "label": "API_KEY",
      "secretReferenceId": "b2c3d4e5-2222-3333-4444-555566667777"
    }
  ]
}
```

**SDK Code**

```python A binding with a rule
import requests

url = "https://api.usepassport.ai/public/v1/endpoints/endpointId/secret-bindings"

payload = { "bindings": [
        {
            "allowedLocations": {
                "headers": ["authorization"],
                "v": 1
            },
            "label": "Authorization",
            "secretReferenceId": "5c6d7e8f-9a0b-1c2d-3e4f-5a6b7c8d9e0f"
        }
    ] }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.json())
```

```javascript A binding with a rule
const url = 'https://api.usepassport.ai/public/v1/endpoints/endpointId/secret-bindings';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"bindings":[{"allowedLocations":{"headers":["authorization"],"v":1},"label":"Authorization","secretReferenceId":"5c6d7e8f-9a0b-1c2d-3e4f-5a6b7c8d9e0f"}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go A binding with a rule
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.usepassport.ai/public/v1/endpoints/endpointId/secret-bindings"

	payload := strings.NewReader("{\n  \"bindings\": [\n    {\n      \"allowedLocations\": {\n        \"headers\": [\n          \"authorization\"\n        ],\n        \"v\": 1\n      },\n      \"label\": \"Authorization\",\n      \"secretReferenceId\": \"5c6d7e8f-9a0b-1c2d-3e4f-5a6b7c8d9e0f\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby A binding with a rule
require 'uri'
require 'net/http'

url = URI("https://api.usepassport.ai/public/v1/endpoints/endpointId/secret-bindings")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"bindings\": [\n    {\n      \"allowedLocations\": {\n        \"headers\": [\n          \"authorization\"\n        ],\n        \"v\": 1\n      },\n      \"label\": \"Authorization\",\n      \"secretReferenceId\": \"5c6d7e8f-9a0b-1c2d-3e4f-5a6b7c8d9e0f\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java A binding with a rule
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://api.usepassport.ai/public/v1/endpoints/endpointId/secret-bindings")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"bindings\": [\n    {\n      \"allowedLocations\": {\n        \"headers\": [\n          \"authorization\"\n        ],\n        \"v\": 1\n      },\n      \"label\": \"Authorization\",\n      \"secretReferenceId\": \"5c6d7e8f-9a0b-1c2d-3e4f-5a6b7c8d9e0f\"\n    }\n  ]\n}")
  .asString();
```

```php A binding with a rule
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.usepassport.ai/public/v1/endpoints/endpointId/secret-bindings', [
  'body' => '{
  "bindings": [
    {
      "allowedLocations": {
        "headers": [
          "authorization"
        ],
        "v": 1
      },
      "label": "Authorization",
      "secretReferenceId": "5c6d7e8f-9a0b-1c2d-3e4f-5a6b7c8d9e0f"
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp A binding with a rule
using RestSharp;

var client = new RestClient("https://api.usepassport.ai/public/v1/endpoints/endpointId/secret-bindings");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"bindings\": [\n    {\n      \"allowedLocations\": {\n        \"headers\": [\n          \"authorization\"\n        ],\n        \"v\": 1\n      },\n      \"label\": \"Authorization\",\n      \"secretReferenceId\": \"5c6d7e8f-9a0b-1c2d-3e4f-5a6b7c8d9e0f\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift A binding with a rule
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["bindings": [
    [
      "allowedLocations": [
        "headers": ["authorization"],
        "v": 1
      ],
      "label": "Authorization",
      "secretReferenceId": "5c6d7e8f-9a0b-1c2d-3e4f-5a6b7c8d9e0f"
    ]
  ]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.usepassport.ai/public/v1/endpoints/endpointId/secret-bindings")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```