CloudPDF
DocsPricing
Start building

Reorder form calculations

POST/v1/docs/{docId}/layers/{layerName}/form/calculations/reorderv3.0.0-next.15

Change the form's calculation order, the order its fields' calculate scripts run in: the fields go together, in the order given, next to a neighbour field or to the start (`'start'`) or end (`'end'`). Every field named must have a calculate script, which puts it in the order. Returns the whole new order.

Authentication#

Any one of these credentials is accepted.

API token

The deployment's static root credential (CLOUDPDF_API_AUTH_TOKENS), valid on every surface.

Document token

Doc-scoped JWT, valid only on the /v1/docs/{docId} subtree it names, gated by the capability scopes it carries (each operation's x-required-capability).

Document capabilitydoc.forms.modify

Parameters#

docIdpathstringrequired
layerNamepathstringrequired
X-Document-Passwordheaderstring

Base64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead.

Idempotency-Keyheaderstring

Names the change: 1 to 255 printable ASCII characters. A retry under the same key on the same layer answers with what the first request committed, and changes nothing.

Request body#

application/jsonDocFormsReorderCalculationsRequestrequired
fieldsFormFieldRef[]required
kind =
kind"objectNumber"required
objectNumberintegerrequired
positionFieldPositionrequired
one of

A complete body for each shape. Strings stand in for your own values.

{
  "fields": {
    "kind": "objectNumber",
    "objectNumber": 1
  },
  "position": "start"
}

SDK examples#

The selected SDK is remembered across the API reference. Values are examples; replace them with identifiers and input from your application.

This body offers a choice, and the example takes one branch: it sends fields as objectNumber. The request body above carries the other shape — fqn.

import { CloudPDFClient } from "@cloudpdf/sdk";

const client = new CloudPDFClient({
  baseUrl: "https://yourhost.com/path/to/api",
  token: "<token>",
});

await client.doc.forms.reorderCalculations({
  docId: "docId",
  layerName: "layerName",
  fields: [{
      kind: "objectNumber",
      objectNumber: 1
    }],
  position: "start"
});

Responses#

200OK
application/jsonDocFormsReorderCalculations200Response
calculationOrderFormFieldRef[]
kind =
kind"objectNumber"
objectNumberinteger
metaFormMutationMeta
affectedPagesPageRef[]
kind"objectNumber"
objectNumberinteger
cacheDeltaCacheDelta
opIdstring
undoableboolean
changedFieldsFormFieldRef[]
kind =
kind"objectNumber"
objectNumberinteger
changedWidgetsFormWidget[]
refAnnotationRef
objectNumberinteger
pagePageRef
redrawnWidgetsFormWidget[]
refAnnotationRef
objectNumberinteger
pagePageRef
400Bad request
application/jsonDocFormsReorderCalculations400Response
404Not found
application/jsonDocFormsReorderCalculations404Response
defaultError
application/jsonEngineErrorPayload
name"EngineError"
code"Unknown" | "InvalidArg" | "DocNotOpen" | "DocOpenFailed" | "DocPasswordRequired" | "DocPasswordIncorrect" | "SharePasswordRequired" | "Aborted" | "Network" | "Unauthenticated" | "Forbidden" | "NotFound" | "WireFormat" | "RuntimeUnavailable" | "LayerVersionConflict" | "NotImplemented" | "MalformedPdf" | "SigningPending" | "SigningExpired" | "SigningVersionMismatch" | "SignatureRefused" | "ProtectedDocument" | "StaleBase" | "PayloadTooLarge" | "ObjectNumberUnavailable" | "LayerFull" | "ChangeConflict" | "UndoUnavailable" | "IdempotencyKeyReused"
messagestring
detailsobjectoptional