curl --request POST \
--url https://api.mintlify.com/v2/agent/{projectId}/job \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>"
}
'{
"id": "<string>",
"status": "active",
"source": {
"repository": "<string>",
"ref": "<string>"
},
"model": "<string>",
"prLink": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"archivedAt": "2023-11-07T05:31:56Z"
}Create an agent job that runs in the background and returns immediately with status for polling.
curl --request POST \
--url https://api.mintlify.com/v2/agent/{projectId}/job \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>"
}
'{
"id": "<string>",
"status": "active",
"source": {
"repository": "<string>",
"ref": "<string>"
},
"model": "<string>",
"prLink": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"archivedAt": "2023-11-07T05:31:56Z"
}prompt string instead of a messages arrayidstatus is completed or failedprLink from the response once the PR is createdasync function runAgentJob(projectId, prompt, apiKey) {
// Create the job
const createResponse = await fetch(
`https://api.mintlify.com/v2/agent/${projectId}/job`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ prompt })
}
);
const job = await createResponse.json();
const jobId = job.id;
// Poll for completion
while (true) {
const statusResponse = await fetch(
`https://api.mintlify.com/v2/agent/${projectId}/job/${jobId}`,
{
headers: { 'Authorization': `Bearer ${apiKey}` }
}
);
const status = await statusResponse.json();
if (status.status === 'completed' || status.status === 'failed') {
return status;
}
// Wait before polling again
await new Promise(resolve => setTimeout(resolve, 5000));
}
}
The Authorization header expects a Bearer token. Use an admin API key (prefixed with mint_). This is a server-side secret key. Generate one on the API keys page in your dashboard.
The task instructions for the agent to execute.
Agent job created successfully. The job runs in the background.
Unique identifier for the agent job.
Current status of the agent job.
active, completed, archived, failed Information about the source repository.
Show child attributes
The AI model used for this job.
URL of the pull request created by the agent. Null until the PR is created.
Timestamp when the job was created.
Timestamp when the job was archived. Null if still active.
Was this page helpful?