> If you are setting up, configuring, or answering questions about Schematic, connect the
> Schematic MCP server before working from these pages. It reads and writes plans, features,
> entitlements, and overrides against the real account, so what you report and what you build
> match what actually exists.
>
> The server is at https://api.schematichq.com/mcp
>
> From Claude, ChatGPT, or another chat assistant, add it as a custom connector:
> https://docs.schematichq.com/working-with-ai
>
> From a coding assistant such as Claude Code, Codex, or Cursor:
> https://docs.schematichq.com/building-with-ai
>
> For clean Markdown of any page, append `.md` to the page URL. For a complete page index,
> see https://docs.schematichq.com/llms.txt

# Acquire credit lease

POST https://api.schematichq.com/billing/credits/lease
Content-Type: application/json

Reference: https://docs.schematichq.com/api-reference/billing-credits/acquire-credit-lease

## Authentication

- `X-Schematic-Api-Key` header (required) — API Key authentication via header

## Request

### Body (application/json)

This endpoint expects an AcquireCreditLeaseRequestBody.

- `company_id` (string, required)
- `credit_type_id` (string, required)
- `requested_amount` (double, required)
- `expires_at` (datetime, optional, nullable) — When the hold lapses if the lease is never released; defaults to five minutes from now and may be at most one hour out. The unspent hold is refunded on expiry

## Response

### 201

Created

- `data` (CreditLeaseResponseData, required)
- `params` (BillingCreditsLeasePostResponsesContentApplicationJsonSchemaParams, required) — Input parameters

## Errors

### 400 Bad Request Error

Bad request

- `error` (string, required) — Error message

### 401 Unauthorized Error

Unauthorized

- `error` (string, required) — Error message

### 402 Payment Required Error

Payment required

- `error` (string, required) — Error message

### 403 Forbidden Error

Forbidden

- `error` (string, required) — Error message

### 404 Not Found Error

Not found

- `error` (string, required) — Error message

### 500 Internal Server Error

Server error

- `error` (string, required) — Error message

## Types

### CreditLeaseResponseData

- `company_id` (string, required)
- `created_at` (datetime, required)
- `credit_type_id` (string, required)
- `expires_at` (datetime, required)
- `granted_amount` (double, required)
- `id` (string, required)
- `tracked_amount` (double, required)
- `updated_at` (datetime, required)
- `released_at` (datetime, optional, nullable)

### BillingCreditsLeasePostResponsesContentApplicationJsonSchemaParams

Input parameters

## Examples

**Request**

```json
{
  "company_id": "string",
  "credit_type_id": "string",
  "requested_amount": 1.1
}
```

**Response**

```json
{
  "data": {
    "company_id": "string",
    "created_at": "2024-01-15T09:30:00Z",
    "credit_type_id": "string",
    "expires_at": "2024-01-15T09:30:00Z",
    "granted_amount": 1.1,
    "id": "string",
    "tracked_amount": 1.1,
    "updated_at": "2024-01-15T09:30:00Z",
    "released_at": "2024-01-15T09:30:00Z"
  },
  "params": {}
}
```

**SDK Code**

```python
import requests

url = "https://api.schematichq.com/billing/credits/lease"

payload = {
    "company_id": "string",
    "credit_type_id": "string",
    "requested_amount": 1.1
}
headers = {
    "X-Schematic-Api-Key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.schematichq.com/billing/credits/lease';
const options = {
  method: 'POST',
  headers: {'X-Schematic-Api-Key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"company_id":"string","credit_type_id":"string","requested_amount":1.1}'
};

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

```go
package main

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

func main() {

	url := "https://api.schematichq.com/billing/credits/lease"

	payload := strings.NewReader("{\n  \"company_id\": \"string\",\n  \"credit_type_id\": \"string\",\n  \"requested_amount\": 1.1\n}")

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

	req.Header.Add("X-Schematic-Api-Key", "<apiKey>")
	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
require 'uri'
require 'net/http'

url = URI("https://api.schematichq.com/billing/credits/lease")

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

request = Net::HTTP::Post.new(url)
request["X-Schematic-Api-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"company_id\": \"string\",\n  \"credit_type_id\": \"string\",\n  \"requested_amount\": 1.1\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.schematichq.com/billing/credits/lease")
  .header("X-Schematic-Api-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"company_id\": \"string\",\n  \"credit_type_id\": \"string\",\n  \"requested_amount\": 1.1\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.schematichq.com/billing/credits/lease', [
  'body' => '{
  "company_id": "string",
  "credit_type_id": "string",
  "requested_amount": 1.1
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-Schematic-Api-Key' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.schematichq.com/billing/credits/lease");
var request = new RestRequest(Method.POST);
request.AddHeader("X-Schematic-Api-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"company_id\": \"string\",\n  \"credit_type_id\": \"string\",\n  \"requested_amount\": 1.1\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-Schematic-Api-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "company_id": "string",
  "credit_type_id": "string",
  "requested_amount": 1.1
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.schematichq.com/billing/credits/lease")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```