Layers

Create a New Layer

This endpoint allows you to create a new layer for a document. It supports three modes of operation:

  • create a new layer based on a source layer: this essentially copies a layer in a document to a new layer in the same document
  • create a new layer based on an Instant JSON file: this creates a new layer by copying document's base layer and applying the provided Instant JSON payload
  • create a new layer based on a source layer and an Instant JSON file: the same as above, but instead of copying the base layer, the source layer is used

NOTE: When the provided source layer name doesn't exist, the base layer is used instead.

In case of success, the new layer name is returned along with a list of errors from importing the Instant JSON file into the layer.

post/api/documents/{documentId}/layers

Request

  • Base URL: http://localhost:5000
  • URL: http://localhost:5000/api/documents/{documentId}/layers
  • Auth: one of:
    • API key in header Authorization
    • HTTP bearer

Path parameters

documentIdstring required

The document ID

Headers

pspdfkit-pdf-passwordstring

The PDF document password.

The value can be either a plain-text password or a base64 encoded password in a form base64:<encoded-password>. Use the Base64 encoding if your password contains characters that are not allowed in HTTP header or would be otherwise mangled (e.g. trailing or leading spaces)

If the document is password protected, any operations performed on it require supplying a password.

Request body

namestring required

The name of the new layer.

source_layer_namestring

The name of the layer the new one will be based on. If not provided or the layer with the given name doesn't exist, the base layer is assumed instead.

Example request

{
  "name": "my-layer",
  "source_layer_name": "my-existing-layer"
}

Response

The new layer has been created.

Example response

{
  "data": {
    "name": "my-layer"
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.