> This page is for Workforce.

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

# Register allowed callback origin

POST https://ah-api.merge.dev/api/v1/allowed-callback-origins/
Content-Type: application/json

Registers an origin (scheme and host, plus port if any). A path, query or fragment in the value is dropped. HTTPS origins and custom app schemes such as `myapp://` are accepted; plain HTTP is accepted only for `http://localhost:PORT`. Registering an origin that is already registered returns the existing origin with a 200, so retries are safe.

Reference: https://docs.merge.dev/merge-workforce/agent-handler/allowed-callback-origins/allowed-callback-origins-create

## Authentication

- `Authorization` header (bearer token, required) — Token-based authentication with required prefix "Bearer"

## Request

### Body (application/json)

This endpoint expects an AllowedCallbackOriginRequest.

- `origin` (string, required)

## Response

### 200

The origin was already registered.

- `id` (string, required)
- `origin` (string, required) — Allowed origin for callback URLs (e.g., 'https://myapp.com' or 'myapp://'). The callback_url's scheme+host must match this origin.
- `created_at` (datetime, required)
- `modified_at` (datetime, required)

### 201

- `id` (string, required)
- `origin` (string, required) — Allowed origin for callback URLs (e.g., 'https://myapp.com' or 'myapp://'). The callback_url's scheme+host must match this origin.
- `created_at` (datetime, required)
- `modified_at` (datetime, required)

## Errors

### 400 Bad Request Error

The origin is invalid.

- `any`

## Examples

**Request**

```json
{
  "origin": "https://app.acme.com"
}
```

**Response**

```json
{
  "id": "3c90c3c0-6d46-4b50-8888-8dd25736052f",
  "origin": "https://app.acme.com",
  "created_at": "2026-10-13T12:00:00Z",
  "modified_at": "2026-10-13T12:00:00Z"
}
```

**SDK Code**

```python Register origin (application/json)
import requests

url = "https://ah-api.merge.dev/api/v1/allowed-callback-origins/"

payload = { "origin": "https://app.acme.com" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Register origin (application/json)
const url = 'https://ah-api.merge.dev/api/v1/allowed-callback-origins/';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"origin":"https://app.acme.com"}'
};

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

```go Register origin (application/json)
package main

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

func main() {

	url := "https://ah-api.merge.dev/api/v1/allowed-callback-origins/"

	payload := strings.NewReader("{\n  \"origin\": \"https://app.acme.com\"\n}")

	req, _ := http.NewRequest("POST", 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 Register origin (application/json)
require 'uri'
require 'net/http'

url = URI("https://ah-api.merge.dev/api/v1/allowed-callback-origins/")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"origin\": \"https://app.acme.com\"\n}"

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

```java Register origin (application/json)
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://ah-api.merge.dev/api/v1/allowed-callback-origins/")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"origin\": \"https://app.acme.com\"\n}")
  .asString();
```

```php Register origin (application/json)
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://ah-api.merge.dev/api/v1/allowed-callback-origins/', [
  'body' => '{
  "origin": "https://app.acme.com"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Register origin (application/json)
using RestSharp;

var client = new RestClient("https://ah-api.merge.dev/api/v1/allowed-callback-origins/");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"origin\": \"https://app.acme.com\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Register origin (application/json)
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["origin": "https://app.acme.com"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://ah-api.merge.dev/api/v1/allowed-callback-origins/")! 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()
```