Skip to main content
POST
/
pdf
/
generate
JavaScript
import Sudopdf from '@sudopdf/sdk';

const client = new Sudopdf({
  apiKey: 'My API Key', // process.env['SUDOPDF_API_KEY'] is the default and can be omitted.
});

const response = await client.pdf.generate({ 
  templateId: 22
  data: { foo: 'bar' } 
});

console.log(response.data);
{
"success": true,
"mode": "sync",
"message": "PDF generated successfully",
"environment": "production",
"data": {
"url": "https://app.sudopdf.com/files/abc123.pdf",
"creditsUsed": 1
}
}

Authorizations

X-API-KEY
string
header
required

Query Parameters

sync
boolean
default:false

Whether to generate the PDF synchronously. Not recomended for production use

Body

application/json

PDF to generate

data
object
required

Any data that use inside the template. Prefer metadata if you are not planning to use that data inside template

templateId
string

Unique Id of your template you like to render

url
string<uri>

You can pass a url directly and get the webpage rendered.

html
string
metadata
object

Data associated with this render but not used inside template.

renderOptions
object

Advanced rendering options for PDF generation

Response

PDF generation response

Unified PDF generation success response

success
boolean
required

Indicates if the request was successful

Example:

true

mode
enum<string>
required

Response mode - sync for immediate PDF generation, async for background processing

Available options:
sync,
async
message
string
required

Human-readable summary of the response

Example:

"PDF generated successfully"

data
object
required

Data payload for synchronous PDF generation

  • Option 1
  • Option 2
environment
enum<string>

Environment where the PDF was generated

Available options:
development,
production