Approvals Overview
9 min
the approvals api lets you drive nue approvals pro programmatically discover which approval process applies to a record, preview the approval path before submitting, and submit, approve, reject, recall, or reassign approvals from your own application the api runs on the same approval engine as the approvals pro ui a quote submitted through the api follows the same paths, steps, approvers, and record locking rules as one submitted by a sales rep, and appears in the same approval history nothing about how you configure approvals changes availability the approvals api is available in nue release 2636 required permission your api key must be associated with a role that has permission to view and act on approvals under the "nue on salesforce" category requests are executed against a salesforce session, so the acting user must also be able to see the underlying record endpoints endpoint method description /cpq/approval processes get list the approval processes configured for an object /cpq/approvals\ preview post preview the approval path without submitting /cpq/approvals\ submit post submit a record for approval /cpq/approvals\ recall post recall a submitted record so it can be edited /cpq/approvals\ approve post approve one or more pending approvals /cpq/approvals\ reject post reject one or more pending approvals /cpq/approvals\ reassign post route pending approvals to a different approver /cpq/approval requests get get approval status for a record /cpq/approvals get list an approver's pending approvals read operations are plain get requests actions use colon verb routes, matching the convention used elsewhere in the cpq api such as post /cpq/quotes\ preview authentication include your api key in the request header curl x post 'https //api nue io/cpq/approvals\ preview' \\ h 'nue api key your api key' \\ h 'content type application/json' the response envelope every endpoint returns the same envelope, whether it succeeds or fails { "status" "success", "data" { }, "warnings" \[], "errors" \[] } field type description status string success or failure data object the typed payload for the endpoint warnings array non fatal messages errors array coded failures empty on success each entry in warnings and errors has severity , code , and message { "status" "failure", "data" null, "warnings" \[], "errors" \[ { "severity" "error", "code" "missing parameter", "message" "recordid is required" } ] } codes are stable; message text is not branch on code rather than matching message strings validation failures return the same envelope a request that fails validation returns http 400 with the envelope above and a missing parameter or invalid parameter error, not a generic error body you can parse every response the same way a typical flow discover which process applies, if you don't already know get /cpq/approval processes?recordid={quoteid} preview the path so you can show the rep what approvals the quote will need post /cpq/approvals\ preview submit the quote when the rep is ready post /cpq/approvals\ submit track where it stands get /cpq/approval requests?recordid={quoteid} act as approvals come due post /cpq/approvals\ approve or \ reject step 2 is the one most worth building in because a preview writes nothing, you can call it as the rep edits a quote and warn them that a discount will pull in a vp approval while the number can still be changed recording the channel every action endpoint accepts an optional source describing where the request came from, recorded on the approval so an auditor can distinguish a human approval from a programmatic one it must be one of ui · email · api · flow any other value is rejected with invalid parameter when you omit it, the action records api acting on behalf of another user the approve , reject , recall , and reassign endpoints accept an optional actor — a salesforce user id to act as use it when a service integration completes an action a specific person authorized the approval history records the actor, so the audit trail names a person rather than the integration apex the same nine operations are available as apex global methods on appro globalapprovalserviceapi for logic running inside salesforce the inputs and field shapes match; the only difference is that apex returns succeed where rest returns success