Skip to main content
PUT
/
workspaces
/
{id}
/
budgets
/
{interval}
Create or update a workspace budget
curl --request PUT \
  --url https://openrouter.ai/api/v1/workspaces/{id}/budgets/{interval} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "limit_usd": 100
}
'
import requests

url = "https://openrouter.ai/api/v1/workspaces/{id}/budgets/{interval}"

payload = { "limit_usd": 100 }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

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

print(response.text)
const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({limit_usd: 100})
};

fetch('https://openrouter.ai/api/v1/workspaces/{id}/budgets/{interval}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://openrouter.ai/api/v1/workspaces/{id}/budgets/{interval}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'limit_usd' => 100
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

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

func main() {

url := "https://openrouter.ai/api/v1/workspaces/{id}/budgets/{interval}"

payload := strings.NewReader("{\n \"limit_usd\": 100\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(string(body))

}
HttpResponse<String> response = Unirest.put("https://openrouter.ai/api/v1/workspaces/{id}/budgets/{interval}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"limit_usd\": 100\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://openrouter.ai/api/v1/workspaces/{id}/budgets/{interval}")

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 \"limit_usd\": 100\n}"

response = http.request(request)
puts response.read_body
{
  "data": {
    "created_at": "2025-08-24T10:30:00Z",
    "id": "770e8400-e29b-41d4-a716-446655440000",
    "limit_usd": 100,
    "reset_interval": "monthly",
    "updated_at": "2025-08-24T15:45:00Z",
    "workspace_id": "550e8400-e29b-41d4-a716-446655440000"
  }
}
{
"error": {
"code": 400,
"message": "Invalid request parameters"
}
}
{
"error": {
"code": 401,
"message": "Missing Authentication header"
}
}
{
"error": {
"code": 404,
"message": "Resource not found"
}
}
{
"error": {
"code": 500,
"message": "Internal Server Error"
}
}

Authorizations

Authorization
string
header
required

API key as bearer token in Authorization header

Path Parameters

id
string
required

The workspace ID (UUID) or slug

Minimum string length: 1
Example:

"production"

interval
enum<string>
required

Budget reset interval. Use "lifetime" for a one-time budget that never resets.

Available options:
daily,
weekly,
monthly,
lifetime
Example:

"monthly"

Body

application/json
limit_usd
number<double>
required

Spending limit in USD. Must be greater than 0.

Example:

100

Response

Budget created or updated successfully

data
object
required

The created or updated budget

Example:
{
"created_at": "2025-08-24T10:30:00Z",
"id": "770e8400-e29b-41d4-a716-446655440000",
"limit_usd": 100,
"reset_interval": "monthly",
"updated_at": "2025-08-24T15:45:00Z",
"workspace_id": "550e8400-e29b-41d4-a716-446655440000"
}