Link Search Menu Expand Document

Background Jobs Check

Checks status of background job that was previously created with PDF.co API.

Available methods

[POST] /job/check

  • jobId required. Id of background that was started asynchronously. Must be a String. To start new async background job, you should set async to true for API methods.
  • force optional. Set to true to forcely check the status of the background job. Intended to be used with really long and heavy background jobs only.

Returns JSON with status of the background job.

Available status values:

  • working background job is currently in work or does not exist.
  • success background job was successfully finished.
  • failed background job failed for some reason (see message for more details).
  • aborted background job was aborted.
  • unknown unknown background job id. Available only when force is set to true for input request.

Description

  • Method: POST
  • URL: /v1/job/check

Query parameters

No query parameters accepted.

Body payload

{
    "jobid": "12345"
}

Example responses

/job/check
{
    "status": "working",
    "remainingCredits": 60227
}

Code Snippets

CURL
curl --location --request POST 'https://api.pdf.co/v1/job/check' \
--header 'x-api-key: ' \
--data-raw '{
    "jobid": "12345"
}'
JavaScript
var myHeaders = new Headers();
myHeaders.append("x-api-key", "");

var raw = "{\n    \"jobid\": \"12345\"\n}";

var requestOptions = {
	method: 'POST',
	headers: myHeaders,
	body: raw,
	redirect: 'follow'
};

fetch("https://api.pdf.co/v1/job/check", requestOptions)
	.then(response => response.text())
	.then(result => console.log(result))
	.catch(error => console.log('error', error));
NodeJs
var request = require('request');
var options = {
	'method': 'POST',
	'url': 'https://api.pdf.co/v1/job/check',
	'headers': {
		'x-api-key': ''
	},
	body: '{\n    "jobid": "12345"\n}'

};
request(options, function (error, response) {
	if (error) throw new Error(error);
	console.log(response.body);
});

PHP
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
	CURLOPT_URL => 'https://api.pdf.co/v1/job/check',
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_ENCODING => '',
	CURLOPT_MAXREDIRS => 10,
	CURLOPT_TIMEOUT => 0,
	CURLOPT_FOLLOWLOCATION => true,
	CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
	CURLOPT_CUSTOMREQUEST => 'POST',
	CURLOPT_POSTFIELDS =>'{
    "jobid": "12345"
}',
	CURLOPT_HTTPHEADER => array(
		'x-api-key: '
	),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Java
import java.io.*;
import okhttp3.*;
public class main {
	public static void main(String []args) throws IOException{
		OkHttpClient client = new OkHttpClient().newBuilder()
			.build();
		MediaType mediaType = MediaType.parse("text/plain");
		RequestBody body = RequestBody.create(mediaType, "{\n    \"jobid\": \"12345\"\n}");
		Request request = new Request.Builder()
			.url("https://api.pdf.co/v1/job/check")
			.method("POST", body)
			.addHeader("x-api-key", "")
			.build();
		Response response = client.newCall(request).execute();
		System.out.println(response.body().string());
	}
}

C#
using System;
using RestSharp;
namespace HelloWorldApplication {
	class HelloWorld {
		static void Main(string[] args) {
			var client = new RestClient("https://api.pdf.co/v1/job/check");
			client.Timeout = -1;
			var request = new RestRequest(Method.POST);
			request.AddHeader("x-api-key", "");
			var body = @"{" + "\n" +
			@"    ""jobid"": ""12345""" + "\n" +
			@"}";
			request.AddParameter("text/plain", body,  ParameterType.RequestBody);
			IRestResponse response = client.Execute(request);
			Console.WriteLine(response.Content);
		}
	}
}

Python
import requests

url = "https://api.pdf.co/v1/job/check"

payload = "{\n    \"jobid\": \"12345\"\n}"
headers = {
	'x-api-key': ''
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Powershell
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("x-api-key", "")

$body = "{`n    `"jobid`": `"12345`"`n}"

$response = Invoke-RestMethod 'https://api.pdf.co/v1/job/check' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json