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

# Submit a search

POST https://campino.tech/api/v1/partner/audience/searches
Content-Type: application/json

Describe the audience you want and start a search. The fee is charged now and the search runs in the background, so this call answers at once with `202`.

A search takes about 2 to 3 minutes. Poll [Get a search](/api-reference/audience-search/get-search) until `status` is `DONE` or `FAILED`.

The `Idempotency-Key` names one search. Send the same key and objective again and you get the same `request_id` back, charged once. Use this to recover from a lost answer. A new search needs a new key.

An account runs one search at a time. A second submission while one is running answers `409` (code `4092`) and charges nothing.

Reference: https://docs.campino.tech/api-reference/audience-search/submit-search

## Authentication

- `Authorization` header (bearer token, required) — Your partner credential, issued by Campino. Send it as `Authorization: Bearer pc_live_...`.

## Request

### Headers

- `Idempotency-Key` (string, required) — A UUID you generate, one per search. Repeating it with the same objective returns the same search; with another objective it answers `409` (`4091`).
- `X-Request-ID` (string, optional) — Optional. A UUID of your own for tracing. It is echoed back.

### Body (application/json)

This endpoint expects a SubmitSearchRequest.

- `objective` (string, required) — Plain-language description of the audience, in Persian or English. 1 to 2,048 characters and at most 8,192 bytes. Leading and trailing spaces are trimmed; control characters are rejected.

## Response

### 202

The search was accepted and is running. On a replay the `status` may already be `DONE` or `FAILED`.

- `status` (enum, required)
  - Allowed values: `success`
- `data` (SubmitSearchResponse, required) — A search that was accepted.
- `error` (any, optional)

## Errors

### 400 Bad Request Error

The wallet balance does not cover the search fee. Error `4000`. Nothing is queued or charged.

- `status` (enum, required)
  - Allowed values: `failure`
- `error` (ErrorDetail, required) — The error inside a failure response.
- `data` (any, optional)

### 401 Unauthorized Error

The credential is missing, malformed, unknown, revoked, expired, not allowed from your address, or sent twice. Error `4012`.

- `status` (enum, required)
  - Allowed values: `failure`
- `error` (ErrorDetail, required) — The error inside a failure response.
- `data` (any, optional)

### 403 Forbidden Error

The wallet cannot be spent from. Error `4031`.

- `status` (enum, required)
  - Allowed values: `failure`
- `error` (ErrorDetail, required) — The error inside a failure response.
- `data` (any, optional)

### 409 Conflict Error

The `Idempotency-Key` was used for another objective (`4091`), or another search of your account is still running (`4092`). Nothing is charged.

- `status` (enum, required)
  - Allowed values: `failure`
- `error` (ErrorDetail, required) — The error inside a failure response.
- `data` (any, optional)

### 422 Unprocessable Entity Error

The request is malformed. Error `4200`, with the rejected fields in `error.fields`.

- `status` (enum, required)
  - Allowed values: `failure`
- `error` (ErrorDetail, required) — The error inside a failure response.
- `data` (any, optional)

### 429 Too Many Requests Error

A rate limit was reached. Wait `Retry-After` seconds. Error `4290`.

- `status` (enum, required)
  - Allowed values: `failure`
- `error` (ErrorDetail, required) — The error inside a failure response.
- `data` (any, optional)

### 500 Internal Server Error

The request could not be recorded or closed on our side. Error `5000` or `5001`. Repeat the request with the same `Idempotency-Key` (for a submission) or the same `request_id`.

- `status` (enum, required)
  - Allowed values: `failure`
- `error` (ErrorDetail, required) — The error inside a failure response.
- `data` (any, optional)

### 502 Bad Gateway Error

Billing is unavailable (`5022`). This is not a balance shortfall. A fee already taken is refunded.

- `status` (enum, required)
  - Allowed values: `failure`
- `error` (ErrorDetail, required) — The error inside a failure response.
- `data` (any, optional)

### 503 Service Unavailable Error

The rate limiter is unavailable. Error `5030`. Retry after a few seconds.

- `status` (enum, required)
  - Allowed values: `failure`
- `error` (ErrorDetail, required) — The error inside a failure response.
- `data` (any, optional)

## Types

### SubmitSearchResponse

A search that was accepted.

- `request_id` (string, required) — The search. Use it to poll and to buy.
- `status` (enum, required) — `IN_PROGRESS` while the search runs, then `DONE` or `FAILED`. The last two never change.
  - Allowed values: `IN_PROGRESS`, `DONE`, `FAILED`
- `search_cost_toman` (integer, required) — The fee, charged at submission.
- `results_unit_price_toman` (integer, required) — The price of one phone number when you buy results. Frozen for this search.
- `balance_toman` (integer, required) — Your wallet balance after the charge.
- `created_at` (datetime, required) — When the search was accepted.

### ErrorDetail

The error inside a failure response.

- `code` (integer, required) — Application error code. See the Errors page.
- `message` (string, required) — A fixed text for the code. Match on `code`, not on `message`.
- `fields` (list of FieldError, optional, nullable) — Present for `4200` only.

### FieldError

One rejected field.

- `location` (list of string, required) — Path to the field.
- `type` (string, required)
- `message` (string, required)

## Examples

**Request**

```json
{
  "objective": "معاملات طلا"
}
```

**Response**

```json
{
  "status": "success",
  "data": {
    "request_id": "3f1c2a7e-8b41-4c1d-9a55-6d2f0e7b9c10",
    "status": "IN_PROGRESS",
    "search_cost_toman": 50000,
    "results_unit_price_toman": 400,
    "balance_toman": 950000,
    "created_at": "2026-12-02T09:30:00Z"
  }
}
```

**SDK Code**

```python A Persian objective
import requests

url = "https://campino.tech/api/v1/partner/audience/searches"

payload = { "objective": "معاملات طلا" }
headers = {
    "Idempotency-Key": "b6a1c2d4-0f3e-4a8b-9d7c-1e2f3a4b5c6d",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript A Persian objective
const url = 'https://campino.tech/api/v1/partner/audience/searches';
const options = {
  method: 'POST',
  headers: {
    'Idempotency-Key': 'b6a1c2d4-0f3e-4a8b-9d7c-1e2f3a4b5c6d',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: '{"objective":"معاملات طلا"}'
};

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

```go A Persian objective
package main

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

func main() {

	url := "https://campino.tech/api/v1/partner/audience/searches"

	payload := strings.NewReader("{\n  \"objective\": \"معاملات طلا\"\n}")

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

	req.Header.Add("Idempotency-Key", "b6a1c2d4-0f3e-4a8b-9d7c-1e2f3a4b5c6d")
	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 A Persian objective
require 'uri'
require 'net/http'

url = URI("https://campino.tech/api/v1/partner/audience/searches")

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

request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = 'b6a1c2d4-0f3e-4a8b-9d7c-1e2f3a4b5c6d'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"objective\": \"معاملات طلا\"\n}"

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

```java A Persian objective
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://campino.tech/api/v1/partner/audience/searches")
  .header("Idempotency-Key", "b6a1c2d4-0f3e-4a8b-9d7c-1e2f3a4b5c6d")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"objective\": \"معاملات طلا\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://campino.tech/api/v1/partner/audience/searches', [
  'body' => '{
  "objective": "معاملات طلا"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
    'Idempotency-Key' => 'b6a1c2d4-0f3e-4a8b-9d7c-1e2f3a4b5c6d',
  ],
]);

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

```csharp A Persian objective
using RestSharp;

var client = new RestClient("https://campino.tech/api/v1/partner/audience/searches");
var request = new RestRequest(Method.POST);
request.AddHeader("Idempotency-Key", "b6a1c2d4-0f3e-4a8b-9d7c-1e2f3a4b5c6d");
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"objective\": \"معاملات طلا\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift A Persian objective
import Foundation

let headers = [
  "Idempotency-Key": "b6a1c2d4-0f3e-4a8b-9d7c-1e2f3a4b5c6d",
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["objective": "معاملات طلا"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://campino.tech/api/v1/partner/audience/searches")! 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()
```