Introduction
API endpoints for document generation
Welcome
You can find the open API JSON file below.
Onedoc API endpoints
View the OpenAPI specification file
Authentication
All Onedoc API endpoints are authenticated using an API key and picked up from the request header.
"header": [
{
"x-api-key": "XXXX-XXXX-XXXX-XXXX-XXXX"
}
]
Usage
Rendering a PDF with the Onedoc API takes 3 steps:
Initiate document rendering (Onedoc API)
This step creates a bucket with SignedUrls for each file your document needs to be rendered.
Upload your assets to their respective buckets using signedUrls (Supabase API)
This is when you load the bucket with all the necessary files. One API call should be made per file.
Generate your document (Onedoc API)
Onedoc renders your document from your loaded bucket!
1. Initiate document rendering
In order to render a document, intiate rendering with api/docs/initiate.
This step returns a list of signed bucket URLs to which you should upload your assets’ content. You should include:
- an
ìndex.html
file that should include your bundled react code and/or raw html. All stylesheets or other asset imports should be done with relative paths. (MANDATORY) - stylesheets with a path matching the relative one in the
ìndex.html
(OPTIONAL) - all other assets such as images, logos etc. (OPTIONAL)
Make sure all imports are relative and make sure they match the paths you provide in the request body.
This query will return a list of SignedUrl, path, token triple.
2. Upload your assets to their respective buckets using signedUrls.
Then, upload all your assets to the paths you the specified in the intiate using the returned signed Urls.
Uploading an asset using a signed URL consists in sending a PUT
request with the token and the asset at {signedUrl}/object/upload/sign/{path}.
Below is a helper function to upload assets to a bucket using a signed Url for Node JS. This implementation is specific to supabase, specifically in our URL and path management.
3. Generate your document by specifying your bucket identifier, auth and options.
You can generate your document using api/docs/generate. This step lets Onedoc know the bucket is loaded with the base html, assets (optionally) and that it is ready for rendering to .PDF. You the bucket, password and username are retrieved form the response of the first call to api/docs/initiate.
Was this page helpful?