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

# Create an asynchronous segmentation job (image or video)

POST https://api.segmentationapi.com/v1/jobs
Content-Type: application/json

Queue an image or video segmentation job from previously uploaded task IDs and text prompts. The job runs asynchronously. Poll retrieveJob until status is success, then fetch masks with retrieveJobResult or createJobDownload. Auth is required; there is no anonymous API.


Reference: https://docs.segmentationapi.com/api-reference/jobs/create-job

## Authentication

- `Authorization` header (required) — Unrestricted secret `sk_live_...` or Cognito access token in `Authorization: Bearer ...`

## Request

### Body (application/json)

This endpoint expects a JobCreateRequest.

- `JobCreateRequest`
  - `type`: `image` (image)
    - `prompts` (list of string, required) — Required for all jobs and must include at least one non-empty prompt.
    - `tasks` (list of string, required) — Task ids returned by POST /v1/uploads/presign.
    - `generatePreview` (boolean, optional) — When true, includes a composited preview image in the result.
    - `maskThreshold` (double, optional) — Mask threshold. Defaults to 0.5.
    - `threshold` (double, optional) — Confidence threshold. Defaults to 0.5.
  - `type`: `video` (video)
    - `prompts` (list of string, required)
    - `tasks` (list of string, required) — Single task id returned by POST /v1/uploads/presign.
    - `fps` (double, optional) — Sampling rate in frames per second. Mutually exclusive with numFrames.
    - `generatePreview` (boolean, optional) — When true, includes a baked preview video in the result.
    - `maxFrames` (integer, optional) — Upper bound on processed video frames.
    - `numFrames` (integer, optional) — Number of frames to sample. Mutually exclusive with fps.
    - `scoreThreshold` (double, optional) — Confidence threshold. Defaults to 0.

## Response

### 202

Job accepted

- `jobId` (string, required)
- `type` (enum, required)
  - Allowed values: `image`, `video`
- `totalItems` (integer, required)
- `trial` (TrialAcceptedOverview, optional)

## Errors

### 400 Bad Request Error

Invalid request

- `error` (string, required)
- `message` (string, optional)
- `remainingTokens` (integer, optional)
- `requestedTokens` (integer, optional)
- `expiresAt` (datetime, optional)
- `activeJobId` (string, optional)
- `upgradeUrl` (string, optional)
- `retryAfterSeconds` (integer, optional)

### 401 Unauthorized Error

Authentication is missing, invalid, or expired

- `error` (string, required)
- `message` (string, optional)
- `remainingTokens` (integer, optional)
- `requestedTokens` (integer, optional)
- `expiresAt` (datetime, optional)
- `activeJobId` (string, optional)
- `upgradeUrl` (string, optional)
- `retryAfterSeconds` (integer, optional)

### 402 Payment Required Error

Trial access is expired, exhausted, or insufficient

- `error` (string, required)
- `message` (string, optional)
- `remainingTokens` (integer, optional)
- `requestedTokens` (integer, optional)
- `expiresAt` (datetime, optional)
- `activeJobId` (string, optional)
- `upgradeUrl` (string, optional)
- `retryAfterSeconds` (integer, optional)

### 403 Forbidden Error

The provided taskId does not belong to the authenticated account

- `error` (string, required)
- `message` (string, optional)
- `remainingTokens` (integer, optional)
- `requestedTokens` (integer, optional)
- `expiresAt` (datetime, optional)
- `activeJobId` (string, optional)
- `upgradeUrl` (string, optional)
- `retryAfterSeconds` (integer, optional)

### 409 Conflict Error

Request conflicts with the current resource state

- `error` (string, required)
- `message` (string, optional)
- `remainingTokens` (integer, optional)
- `requestedTokens` (integer, optional)
- `expiresAt` (datetime, optional)
- `activeJobId` (string, optional)
- `upgradeUrl` (string, optional)
- `retryAfterSeconds` (integer, optional)

### 500 Internal Server Error

Internal server error

- `error` (string, required)
- `message` (string, optional)
- `remainingTokens` (integer, optional)
- `requestedTokens` (integer, optional)
- `expiresAt` (datetime, optional)
- `activeJobId` (string, optional)
- `upgradeUrl` (string, optional)
- `retryAfterSeconds` (integer, optional)

### 502 Bad Gateway Error

Failed to enqueue job for background processing

- `error` (string, required)
- `message` (string, optional)
- `remainingTokens` (integer, optional)
- `requestedTokens` (integer, optional)
- `expiresAt` (datetime, optional)
- `activeJobId` (string, optional)
- `upgradeUrl` (string, optional)
- `retryAfterSeconds` (integer, optional)

### 503 Service Unavailable Error

Free trial queue capacity is temporarily unavailable

- `error` (string, required)
- `message` (string, optional)
- `remainingTokens` (integer, optional)
- `requestedTokens` (integer, optional)
- `expiresAt` (datetime, optional)
- `activeJobId` (string, optional)
- `upgradeUrl` (string, optional)
- `retryAfterSeconds` (integer, optional)

## Types

### TrialAcceptedOverview

- `remainingTokens` (integer, required)
- `expiresAt` (datetime, required)

## Examples

**Request**

```json
{
  "type": "image",
  "prompts": [
    "string"
  ],
  "tasks": [
    "a1b2c3d4-e5f6-7890-abcd-ef1234567890.png",
    "b2c3d4e5-f6a7-8901-bcde-f12345678901.jpg"
  ]
}
```

**Response**

```json
{
  "jobId": "job-abc-987",
  "type": "image",
  "totalItems": 2
}
```

**SDK Code**

```python
import requests

url = "https://api.segmentationapi.com/v1/jobs"

payload = {
    "type": "image",
    "prompts": ["string"],
    "tasks": ["a1b2c3d4-e5f6-7890-abcd-ef1234567890.png", "b2c3d4e5-f6a7-8901-bcde-f12345678901.jpg"]
}
headers = {
    "Authorization": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.segmentationapi.com/v1/jobs';
const options = {
  method: 'POST',
  headers: {Authorization: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"type":"image","prompts":["string"],"tasks":["a1b2c3d4-e5f6-7890-abcd-ef1234567890.png","b2c3d4e5-f6a7-8901-bcde-f12345678901.jpg"]}'
};

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.segmentationapi.com/v1/jobs"

	payload := strings.NewReader("{\n  \"type\": \"image\",\n  \"prompts\": [\n    \"string\"\n  ],\n  \"tasks\": [\n    \"a1b2c3d4-e5f6-7890-abcd-ef1234567890.png\",\n    \"b2c3d4e5-f6a7-8901-bcde-f12345678901.jpg\"\n  ]\n}")

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

	req.Header.Add("Authorization", "<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.segmentationapi.com/v1/jobs")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"type\": \"image\",\n  \"prompts\": [\n    \"string\"\n  ],\n  \"tasks\": [\n    \"a1b2c3d4-e5f6-7890-abcd-ef1234567890.png\",\n    \"b2c3d4e5-f6a7-8901-bcde-f12345678901.jpg\"\n  ]\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.segmentationapi.com/v1/jobs")
  .header("Authorization", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"type\": \"image\",\n  \"prompts\": [\n    \"string\"\n  ],\n  \"tasks\": [\n    \"a1b2c3d4-e5f6-7890-abcd-ef1234567890.png\",\n    \"b2c3d4e5-f6a7-8901-bcde-f12345678901.jpg\"\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.segmentationapi.com/v1/jobs', [
  'body' => '{
  "type": "image",
  "prompts": [
    "string"
  ],
  "tasks": [
    "a1b2c3d4-e5f6-7890-abcd-ef1234567890.png",
    "b2c3d4e5-f6a7-8901-bcde-f12345678901.jpg"
  ]
}',
  'headers' => [
    'Authorization' => '<apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.segmentationapi.com/v1/jobs");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"type\": \"image\",\n  \"prompts\": [\n    \"string\"\n  ],\n  \"tasks\": [\n    \"a1b2c3d4-e5f6-7890-abcd-ef1234567890.png\",\n    \"b2c3d4e5-f6a7-8901-bcde-f12345678901.jpg\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "type": "image",
  "prompts": ["string"],
  "tasks": ["a1b2c3d4-e5f6-7890-abcd-ef1234567890.png", "b2c3d4e5-f6a7-8901-bcde-f12345678901.jpg"]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.segmentationapi.com/v1/jobs")! 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()
```