> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.alphax.asia/llms.txt.
> For full documentation content, see https://docs.alphax.asia/llms-full.txt.

# Update order by ID

PUT https://public-api.alphax.com/orders/{orderId}
Content-Type: application/json

Update order by its ID

Reference: https://docs.alphax.asia/api-reference/alpha-x-api/orders/update-order-by-id

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: alphax-openapi
  version: 1.0.0
paths:
  /orders/{orderId}:
    put:
      operationId: update-order-by-id
      summary: Update order by ID
      description: Update order by its ID
      tags:
        - subpackage_orders
      parameters:
        - name: orderId
          in: path
          required: true
          schema:
            type: string
        - name: X-API-Key
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Order updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Orders_updateOrderById_Response_200'
        '404':
          description: Order not found
          content:
            application/json:
              schema:
                description: Any type
        '422':
          description: Validation errors
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/UpdateOrderByIdRequestUnprocessableEntityError
      requestBody:
        description: Your updated order details (only fields to be updated are required)
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateOrUpdateOrderRequest'
servers:
  - url: https://public-api.alphax.com
  - url: https://public-api.demo.alphax.asia
components:
  schemas:
    CreateOrUpdateOrderRequestLineItemsItems:
      type: object
      properties:
        name:
          type: string
          description: Name of the item (e.g. T-Shirt)
        quantity:
          type: integer
          description: Quantity of the item (e.g. 2)
        unitPrice:
          type: number
          format: double
          description: Unit price of the item (e.g. 10.99)
      title: CreateOrUpdateOrderRequestLineItemsItems
    CreateOrUpdateOrderRequest:
      type: object
      properties:
        reference:
          type: string
          description: Your unique order reference
        currency:
          type: string
          description: Currency in ISO 4217 format (e.g. USD, SGD)
        description:
          type: string
          description: 'Description of the order (e.g. Payment for Order #12345)'
        paidNotificationUrl:
          type:
            - string
            - 'null'
          description: >-
            Your backend URL to receive payment notification (e.g.
            https://your-backend-app.com/payment-notification/ORDER-12345)
        dueNotificationUrl:
          type:
            - string
            - 'null'
          description: >-
            Your backend URL to receive due notification (e.g.
            https://your-backend-app.com/due-notification/ORDER-12345)
        dueAt:
          type:
            - string
            - 'null'
          description: >-
            Due date and time for the order, format: YYYY-MM-DD HH:mm:SS (e.g.
            2026-05-05 22:00:00)
        lineItems:
          type: array
          items:
            $ref: '#/components/schemas/CreateOrUpdateOrderRequestLineItemsItems'
      title: CreateOrUpdateOrderRequest
    Orders_updateOrderById_Response_200:
      type: object
      properties: {}
      description: Empty response body
      title: Orders_updateOrderById_Response_200
    UpdateOrderByIdRequestUnprocessableEntityError:
      type: object
      properties:
        message:
          type: string
      title: UpdateOrderByIdRequestUnprocessableEntityError
  securitySchemes:
    xApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key

```

## SDK Code Examples

```python
import requests

url = "https://public-api.alphax.com/orders/orderId"

payload = {
    "description": "Updated description for Order #123123",
    "dueAt": "2026-06-05 22:00:00"
}
headers = {
    "X-API-Key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://public-api.alphax.com/orders/orderId';
const options = {
  method: 'PUT',
  headers: {'X-API-Key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"description":"Updated description for Order #123123","dueAt":"2026-06-05 22:00:00"}'
};

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://public-api.alphax.com/orders/orderId"

	payload := strings.NewReader("{\n  \"description\": \"Updated description for Order #123123\",\n  \"dueAt\": \"2026-06-05 22:00:00\"\n}")

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

	req.Header.Add("X-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://public-api.alphax.com/orders/orderId")

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

request = Net::HTTP::Put.new(url)
request["X-API-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"description\": \"Updated description for Order #123123\",\n  \"dueAt\": \"2026-06-05 22:00:00\"\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.put("https://public-api.alphax.com/orders/orderId")
  .header("X-API-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"description\": \"Updated description for Order #123123\",\n  \"dueAt\": \"2026-06-05 22:00:00\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://public-api.alphax.com/orders/orderId', [
  'body' => '{
  "description": "Updated description for Order #123123",
  "dueAt": "2026-06-05 22:00:00"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-API-Key' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://public-api.alphax.com/orders/orderId");
var request = new RestRequest(Method.PUT);
request.AddHeader("X-API-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"description\": \"Updated description for Order #123123\",\n  \"dueAt\": \"2026-06-05 22:00:00\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-API-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "description": "Updated description for Order #123123",
  "dueAt": "2026-06-05 22:00:00"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://public-api.alphax.com/orders/orderId")! 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()
```