Deleting a document using our API

Libraries

As of today, we provide the following libraries:

Authentication

In order to generate a PDF through the API, you’ll need to grab your API KEY first.

Head to the My account page using the top-right menu.

Toggle your API KEY by clicking on the Display value link below the API SECRET KEY field and copy your key.

You can then use this key to authenticate every call to the API:

# Method 1: Use the PDFMONKEY_PRIVATE_KEY environment variable.
# No code needed.

# Method 2: Set the private key manually (this will generally go in an initializer).
Pdfmonkey.configure do |config|
  config.private_key = '[API KEY]'
end
curl 'https://api.pdfmonkey.io/api/v1/documents' \
  -H 'Authorization: Bearer [API KEY]'

Delete a document

Here is a code snippet you can use to delete a document:

document_id = '[DOCUMENT ID]'

# Delete a Document directly

Pdfmonkey::Document.delete(document_id)
#=> true

# Delete a Document after fetching it

document = Pdfmonkey::Document.fetch(document_id)
document.delete!
#=> true
curl 'https://api.pdfmonkey.io/api/v1/documents/[DOCUMENT ID]' \
  -X DELETE \
  -H 'Authorization: Bearer [API KEY]'

Be careful to replace [API KEY] and [DOCUMENT ID] with the corresponding information.