POST
/
api
/
job
/
status
curl --request POST \
  --url https://api.docswrite.com/api/job/status \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "jobId": "job-abc123",
  "queueType": "post"
}'
{
  "success": true,
  "data": {
    "id": "job-abc123",
    "state": "completed",
    "progress": 100,
    "returnValue": {},
    "failedReason": "<string>",
    "timestamp": 1234567890,
    "processedOn": 1234567890,
    "finishedOn": 1234567890
  }
}

Additional Information

Usage Examples

Polling for Completion

async function waitForJobCompletion(jobId, token) {
  while (true) {
    const response = await fetch("https://api.docswrite.com/api/job/status", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "x-access-token": token,
      },
      body: JSON.stringify({
        jobId: jobId,
        queueType: "post",
      }),
    });

    const data = await response.json();

    if (data.success && data.data.state === "completed") {
      console.log("Job completed successfully!");
      break;
    } else if (data.success && data.data.state === "failed") {
      console.error("Job failed:", data.data.failedReason);
      break;
    }

    // Wait 5 seconds before checking again
    await new Promise((resolve) => setTimeout(resolve, 5000));
  }
}

Progress Tracking

function trackProgress(jobId, token) {
  const interval = setInterval(async () => {
    const response = await fetch("https://api.docswrite.com/api/job/status", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "x-access-token": token,
      },
      body: JSON.stringify({ jobId, queueType: "post" }),
    });

    const data = await response.json();

    if (data.success) {
      console.log(`Progress: ${data.data.progress}%`);

      if (data.data.state === "completed" || data.data.state === "failed") {
        clearInterval(interval);
      }
    }
  }, 2000);
}

You can only check the status of jobs that you created. The API will return a 403 error if you try to check someone else’s job.

Get Job Status

Check the status of a publishing job using the job ID returned when creating a post.

POST https://api.docswrite.com/api/job/status

Headers

HeaderValue
Content-Typeapplication/json
x-access-tokenYOUR_JWT_TOKEN

Request Body

{
  "jobId": "job-123",
  "queueType": "post"
}

Parameters

ParameterTypeRequiredDescription
jobIdstringYesThe job ID returned when creating a post
queueTypestringNoQueue type, defaults to “post”

Response

Success Response (200 OK)

{
  "success": true,
  "data": {
    "id": "job-123",
    "state": "completed",
    "progress": 100,
    "returnValue": {},
    "failedReason": null,
    "timestamp": 1234567890,
    "processedOn": 1234567890,
    "finishedOn": 1234567890
  }
}

Job States

StateDescription
waitingJob is in the queue waiting to be processed
activeJob is currently being processed
completedJob finished successfully
failedJob failed with an error
delayedJob is scheduled to run later

Response Fields

FieldTypeDescription
idstringThe job ID
statestringCurrent state of the job
progressnumberProgress percentage (0-100)
returnValueobjectResult data when completed
failedReasonstringError message if job failed
timestampnumberJob creation timestamp
processedOnnumberWhen job processing started
finishedOnnumberWhen job finished

cURL Example

curl -X POST 'https://api.docswrite.com/api/job/status' \
  -H 'Content-Type: application/json' \
  -H 'x-access-token: YOUR_JWT_TOKEN' \
  -d '{
    "jobId": "job-123",
    "queueType": "post"
  }'

Error Responses

Unauthorized (401)

{
  "error": true,
  "message": "Unauthorized",
  "details": "Invalid or missing access token"
}

Forbidden (403)

{
  "error": true,
  "message": "Access denied",
  "details": "You can only check the status of jobs that you created"
}

Not Found (404)

{
  "error": true,
  "message": "Job not found",
  "details": "No job found with the provided ID"
}

Authorizations

Authorization
string
header
required

JWT token for authenticated requests

Body

application/json

Job status request

The body is of type object.

Response

200
application/json

Job status retrieved successfully

The response is of type object.