> This page is for version v2 (default).
> For other versions, use one of these documentation indexes:
> - v2 (default): https://docs.paid.ai/v-2/llms.txt

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

# Update order

PUT https://api.agentpaid.io/api/v2/orders/{id}
Content-Type: application/json

Update an order by ID. creationState must equal the order's current state; activate a draft order with POST /orders/\{id}/activate.

Reference: https://docs.paid.ai/api-reference/api-reference/orders/update-order-by-id

## Authentication

- `Authorization` header (bearer token, required) — API Key authentication using Bearer token

## Request

### Path parameters

- `id` (string, required)

### Body (application/json)

This endpoint expects an UpdateOrderRequest.

- `name` (string, optional)
- `startDate` (datetime, optional)
- `endDate` (datetime, optional)
- `subscriptionTerms` (integer, optional)
- `creationState` (enum, optional)
  - Allowed values: `draft`, `active`
- `billingAnchor` (integer, optional) — Day of month for billing anchor (1-31). Defaults to start date day if not provided.
- `paymentTerms` (enum, optional)
  - Allowed values: `DueOnReceipt`, `Net15`, `Net30`, `Net45`, `Net60`, `Net90`
- `externalId` (string, optional)
- `metadata` (map from string to any, optional)
- `billingCustomerId` (string, optional)
- `billingContactIds` (list of string, optional)
- `autoPostInvoices` (boolean, optional)
- `autoSendBillingEmails` (boolean, optional)
- `autoSendPaymentEmails` (boolean, optional)
- `purchaseOrderReference` (string, optional, nullable) — Purchase order number printed on invoices generated from this order.

## Response

### 200

200

- `id` (string, required)
- `customerId` (string, required)
- `billingCustomerId` (string, required, nullable)
- `billingContactIds` (list of string, required)
- `createdAt` (datetime, required)
- `updatedAt` (datetime, required)
- `endDate` (datetime, required, nullable)
- `name` (string, required)
- `startDate` (datetime, required)
- `subscriptionTerms` (integer, required, nullable)
- `currency` (string, required) — Three-letter ISO currency code of the order's amounts.
- `currencyDecimals` (integer, required) — Decimals of this order's amounts, from the currency and how Paid stores it: 2 for USD (4999 is $49.99); for JPY 2 while Paid stores yen in hundredths, then 0. Divide amounts by 10^currencyDecimals; never assume 100.
- `billedAmountNoTax` (double, required)
- `billedTax` (double, required)
- `estimatedTax` (double, required)
- `orderAmount` (double, required)
- `pendingBillingAmount` (double, required)
- `totalAmount` (double, required)
- `totalBilledAmount` (double, required)
- `creationState` (enum, required)
  - Allowed values: `draft`, `active`
- `paymentTerms` (string, required, nullable)
- `number` (double, required)
- `metadata` (map from string to any, required, nullable)
- `showPaymentLink` (boolean, required, nullable)
- `showBankDetails` (boolean, required, nullable)
- `autoPostInvoices` (boolean, required, nullable)
- `autoSendBillingEmails` (boolean, required, nullable)
- `autoSendPaymentEmails` (boolean, required, nullable)
- `version` (integer, required)
- `billingFrequencyOverridden` (boolean, required)
- `purchaseOrderReference` (string, required, nullable)
- `billingFrequencyOverride` (OrderBillingFrequencyOverride, optional)

## Errors

### 400 Bad Request Error

400

- `error` (string, required)
- `code` (string, optional)
- `details` (string, optional)

### 403 Forbidden Error

403

- `error` (string, required)
- `code` (string, optional)
- `details` (string, optional)

### 404 Not Found Error

404

- `error` (string, required)
- `code` (string, optional)
- `details` (string, optional)

### 409 Conflict Error

409

- `error` (string, required)
- `code` (string, optional)
- `details` (string, optional)

### 500 Internal Server Error

500

- `error` (string, required)
- `code` (string, optional)
- `details` (string, optional)

## Types

### OrderBillingFrequencyOverride

- `frequency` (enum, required)
  - Allowed values: `monthly`, `quarterly`, `semiAnnually`, `annual`, `custom`
- `customMonths` (integer, optional, nullable)

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "id": "string",
  "customerId": "string",
  "billingCustomerId": "string",
  "billingContactIds": [
    "string"
  ],
  "createdAt": "2024-01-15T09:30:00Z",
  "updatedAt": "2024-01-15T09:30:00Z",
  "endDate": "2024-01-15T09:30:00Z",
  "name": "string",
  "startDate": "2024-01-15T09:30:00Z",
  "subscriptionTerms": 1,
  "currency": "USD",
  "currencyDecimals": 1,
  "billedAmountNoTax": 1.1,
  "billedTax": 1.1,
  "estimatedTax": 1.1,
  "orderAmount": 1.1,
  "pendingBillingAmount": 1.1,
  "totalAmount": 1.1,
  "totalBilledAmount": 1.1,
  "creationState": "draft",
  "paymentTerms": "string",
  "number": 1.1,
  "metadata": {},
  "showPaymentLink": true,
  "showBankDetails": true,
  "autoPostInvoices": true,
  "autoSendBillingEmails": true,
  "autoSendPaymentEmails": true,
  "version": 1,
  "billingFrequencyOverridden": true,
  "purchaseOrderReference": "string",
  "billingFrequencyOverride": {
    "frequency": "monthly",
    "customMonths": 1
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.agentpaid.io/api/v2/orders/id"

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

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

print(response.json())
```

```javascript
const url = 'https://api.agentpaid.io/api/v2/orders/id';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

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.agentpaid.io/api/v2/orders/id"

	payload := strings.NewReader("{}")

	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
require 'uri'
require 'net/http'

url = URI("https://api.agentpaid.io/api/v2/orders/id")

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 = "{}"

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.put("https://api.agentpaid.io/api/v2/orders/id")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.agentpaid.io/api/v2/orders/id', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.agentpaid.io/api/v2/orders/id");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentpaid.io/api/v2/orders/id")! 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()
```