Skip to main content
POST
/
agent
/
{projectId}
/
job
Create agent job
curl --request POST \
  --url https://api.mintlify.com/v1/agent/{projectId}/job \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "branch": "<string>",
  "messages": [
    {
      "content": "<string>"
    }
  ],
  "asDraft": true,
  "model": "sonnet"
}
'
import requests

url = "https://api.mintlify.com/v1/agent/{projectId}/job"

payload = {
"branch": "<string>",
"messages": [{ "content": "<string>" }],
"asDraft": True,
"model": "sonnet"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

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

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
branch: '<string>',
messages: [{content: '<string>'}],
asDraft: true,
model: 'sonnet'
})
};

fetch('https://api.mintlify.com/v1/agent/{projectId}/job', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mintlify.com/v1/agent/{projectId}/job",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'branch' => '<string>',
'messages' => [
[
'content' => '<string>'
]
],
'asDraft' => true,
'model' => 'sonnet'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

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

func main() {

url := "https://api.mintlify.com/v1/agent/{projectId}/job"

payload := strings.NewReader("{\n \"branch\": \"<string>\",\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"asDraft\": true,\n \"model\": \"sonnet\"\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(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.mintlify.com/v1/agent/{projectId}/job")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"branch\": \"<string>\",\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"asDraft\": true,\n \"model\": \"sonnet\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.mintlify.com/v1/agent/{projectId}/job")

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 \"branch\": \"<string>\",\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"asDraft\": true,\n \"model\": \"sonnet\"\n}"

response = http.request(request)
puts response.read_body
"<string>"
This endpoint creates an agent job based on provided messages and branch information. The job executes asynchronously and returns a streaming response with the execution details and results. If a branch doesn’t exist, the agent creates one. If files are edited successfully, a pull request is automatically created at the end of the job.

Rate limits

The agent API has the following limits:
  • 100 uses per Mintlify project per hour

Suggested usage

For best results, use the useChat hook from ai-sdk to send requests and handle responses.

Authorizations

Authorization
string
header
required

The Authorization header expects a Bearer token. Create an Admin API Key here.

Path Parameters

projectId
string
required

Your project ID. Can be copied from the API keys page in your dashboard.

Body

application/json
branch
string
required

The name of the Git branch that the agent should work on, will be automatically created if it doesn't exist

messages
object[]
required

A list of messages to provide to the agent. A default system prompt is always prepended automatically, so you typically only need to include user messages.

asDraft
boolean
default:true

Control whether the pull request is created in draft or non-draft mode. When true, creates a draft pull request. When false, creates a regular (non-draft) pull request ready for review.

model
enum<string>
default:sonnet

The AI model to use for the agent job. Use sonnet for faster, cost-effective processing. Use opus for more capable, but slower processing.

Available options:
sonnet,
opus

Response

200 - text/plain

Agent job created successfully (streaming response). X-Session-Id Header is sent back in the response

Streaming response containing the agent job execution details and results.