PrizmDoc Cloud-Hosted - Updated
Affinity Tokens
Work File > Affinity Tokens

Requests for WorkFile, MarkupBurner, and RedationCreator resources require an additional bit of data, called an affinity token, to ensure they are routed to the same PrizmDoc server. Getting related requests to the same server is critical as the necessary data is cached locally.

Accusoft RESTful Web Services will automatically generate an affinity token when it receives a POST request for a new ViewingSession, WorkFile, MarkupBurner, RedactionCreator, or ContentConverter resource and return it in the response. Once you have obtained an affinity token, you will need to pass this in with related requests using the "Accusoft-Affinity-Token" HTTP custom header. In the case of a ViewingSession, the affinity token is only required when retrieving or setting the source document WorkFile ID for that session.

The following example request and response sequence demonstrates how an affinity token is used to burn markup into a document. Notice how all requests, (except the first request), use the same affinity token even for subsequent POST requests.

// 1. Create first work file, the source PDF document to burn-in markup.
 POST https://api.accusoft.com/PCCIS/V1/WorkFile?FileExtension=pdf
 Content-Type: application/octet-stream
 [binary data]

200 OK
 Content-Type: application/json
 {
     "fileId": "5qTYa3gzN9gYUb5SzqUhqg",
     "affinityToken": "rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w="
 }

// 2. Create the second work file, the XML markup to burn-in.
 //    Pass in the affinity token generated from the previous request so that this
 //      XML data is stored on the same PrizmDoc server.
 POST https://api.accusoft.com/PCCIS/V1/WorkFile?FileExtension=xml
 Accusoft-Affinity-Token: rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w=
 Content-Type: application/xml
 [xml data]

200 OK
 Content-Type: application/json
 {
     "fileId": " o1bLJwFGxf9QGuTkyrOqig",
     "affinityToken": "rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w="
 }

// 3. Create the markup burner resource, again on the same PrizmDoc server where we created
 //      the work files in the previous requests.
 POST https://api.accusoft.com/PCCIS/V1/MarkupBurner
 Content-Type: application/json
 Accusoft-Affinity-Token: rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w=
 {
     "input": {
         "documentFileId": "5qTYa3gzN9gYUb5SzqUhqg",
         "markupFileId": "o1bLJwFGxf9QGuTkyrOqig"
     }
 }

200 OK
 Content-Type: application/json
 {
     "processId": "Rr64ma-U_HseoPrs6y0iiw",
     "expirationDateTime": "2014-12-03T18:30:49.460Z",
     "input": {
         "documentFileId": "5qTYa3gzN9gYUb5SzqUhqg",
         "markupFileId": " o1bLJwFGxf9QGuTkyrOqig"
     },
     "state": "processing",
     "percentComplete": 0,
     "affinityToken": "rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w="
 }

// 4. Get status of markup burning process until state is “complete”.
GET https://api.accusoft.com/PCCIS/V1/MarkupBurner/Rr64ma-U_HseoPrs6y0iiw
 Accusoft-Affinity-Token: rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w=

200 OK
 Content-Type: application/json
 {
     "processId": "Rr64ma-U_HseoPrs6y0iiw",
     "expirationDateTime": "2014-12-03T18:30:49.460Z",
     "input": {
         "documentFileId": "5qTYa3gzN9gYUb5SzqUhqg",
         "markupFileId": " o1bLJwFGxf9QGuTkyrOqig"
     },
     "state": "complete",
     "percentComplete": 100,
     "output": {
         "documentFileId": "5ufb3ytUb1BxxgSUAk_G9Q"
     },
     "affinityToken": "rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w="
 }

// 5. Get the burned document once the markup burning process is complete
 GET https://api.accusoft.com/PCCIS/V1/WorkFile/5ufb3ytUb1BxxgSUAk_G9Q
 Accusoft-Affinity-Token: rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w=

200 OK
 Content-Type: application/pdf
 [binary data]