DischargeRx API v1
Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.
Getting Started
Token Authentication
All document processing API requests must be authenticated.
Request an authentication token with a request to https://www.dischargerx.com/connect/token
. See
the details for this call in the API specification below.
Add an Authorization
header using the value Bearer <token>
replacing <token>
with the token you received from the call to connect/token
.
Base URLs:
Authentication
-
API Key (Bearer)
- Parameter Name: Authorization, in: header.
Token
Get a token to authenticate API requests
Get an auth token
Code samples
POST https://www.dischargerx.com/connect/token HTTP/1.1
Host: www.dischargerx.com
Content-Type: application/x-www-form-urlencoded
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://www.dischargerx.com/connect/token");
var postData = new List<KeyValuePair<string, string>>>
{
new KeyValuePair<string, string>("grant_type", "client_credentials"),
new KeyValuePair<string, string>("client_id", ClientId),
new KeyValuePair<string, string>("client_secret", ClientSecret),
new KeyValuePair<string, string>("scope", "api")
};
var content = new FormUrlEncodedContent(postData);
var response = await client.PostAsync("/connect/token", content);
var token = await response.Content.ReadAsStringAsync();
Console.WriteLine($"Access token: {token}");
}
POST /connect/token
Returns a token to authenticate further requests
Form parameters
grant_type: string
client_id: string
client_secret: string
scope: string
Parameters
Parameter | In | Type | Required | Description |
---|---|---|---|---|
formData | formData | object | false | No description |
» grant_type | formData | string | true | Use client_credentials |
» client_id | formData | string | true | Your client id |
» client_secret | formData | string | true | Your client secret |
» scope | formData | string | true | Use api |
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | Success | None |
Document Processing
Add security features to PDF documents
List Templates
Code samples
POST https://www.dischargerx.com/api/securitytemplate/list HTTP/1.1
Host: www.dischargerx.com
Content-Type: application/x-www-form-urlencoded
const string outFilePath = @"Templates.txt";
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://www.dischargerx.com");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "Token");
var response = await client.PostAsync("/api/securitytemplate/list", form);
using (var writer = File.Open(outFilePath, FileMode.Create))
{
await (await response.Content.ReadAsStreamAsync()).CopyToAsync(writer);
}
}
GET /api/securitytemplate/list
Use this endpoint to list the security templates for your company.
Body parameter
Parameters
Parameter | In | Type | Required | Description |
---|
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | List of templates | None |
Response Schema
Status Code 200
Name | Type | Required | Description |
---|---|---|---|
anonymous | [SecurityTemplate] | false | An array of security template objects |
» id | string | false | The unique id of the security template |
» name | string | false | The security template name |
Template only
Code samples
POST https://www.dischargerx.com/api/document/create HTTP/1.1
Host: www.dischargerx.com
Content-Type: application/x-www-form-urlencoded
const string outFilePath = @"Create.pdf";
const string templateJson = @"{
""document"": {
""width"": 816,
""height"": 1056,
""xps"": null,
""printOnBack"": false,
""whiteFix"": false,
""repeatSecurity"": false,
""authMark"": null,
""duplexMode"": null,
""tray"": null,
""documentLevelSerialization"": false
},
""pages"": [
{
""captureRegions"": [],
""securityFeatures"": [
{
""id"": 1545083991962,
""x"": 258,
""y"": 478,
""width"": 300,
""height"": 100,
""type"": ""textbox"",
""text"": ""Create"",
""fontName"": ""Helvetica"",
""fontSize"": 12,
""lineSpacing"": 0,
""transform"": 0,
""color"": {
""r"": 240,
""g"": 11,
""b"": 11,
""a"": 1
},
""backgroundColor"": {
""r"": 255,
""g"": 255,
""b"": 255,
""a"": 1
},
""border"": {
""size"": 0,
""color"": {
""r"": 0,
""g"": 0,
""b"": 0,
""a"": 1
}
},
""rotationAngle"": 0,
""placement"": 0,
""scale"": 100,
""autoScale"": false,
""horizontalAlignment"": 0
}
]
}
],
""ui"": {
""currentPageIndex"": 0,
""selectedIndex"": 0,
""dirty"": true,
""saving"": false,
""culture"": {
""languageCode"": ""en"",
""countryCode"": ""US""
},
""documentName"": """",
""workflow"": ""template"",
""siteType"": ""docrity"",
""lastDownTarget"": """",
""mode"": ""design"",
""hoverIndex"": -1
},
""protectSettings"": null
}";
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://www.dischargerx.com");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "Token");
var form = new MultipartFormDataContent
{
{new StringContent(templateJson), "template"}
};
var response = await client.PostAsync("/api/document/create", form);
using (var writer = File.Open(outFilePath, FileMode.Create))
{
await (await response.Content.ReadAsStreamAsync()).CopyToAsync(writer);
}
}
POST /api/document/create
Use this to generate a PDF from a template when no source document exists.
Body parameter
template: string
protectSettings: string
Parameters
Parameter | In | Type | Required | Description |
---|---|---|---|---|
body | body | object | false | No description |
» template | body | string | true | The template JSON |
» protectSettings | body | string | false | The digital protection settings JSON to be applied to the document (see ProtectSettings under Models) |
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | PDF file stream | None |
Template and Values
Code samples
POST https://www.dischargerx.com/api/document/createWithTemplate HTTP/1.1
Host: www.dischargerx.com
Content-Type: application/x-www-form-urlencoded
const string outFilePath = @"CreateWithTemplate.pdf";
const string templateName = @"MyTemplateName";
const string values = @"{""firstName"":""John"",""lastName"":""Doe""}";
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://www.dischargerx.com");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "Token");
var form = new MultipartFormDataContent
{
{ new StringContent(templateName), "templateName" }
{ new StringContent(values), "values" }
};
var response = await client.PostAsync("/api/document/createWithTemplate", form);
using (var writer = File.Open(outFilePath, FileMode.Create))
{
await (await response.Content.ReadAsStreamAsync()).CopyToAsync(writer);
}
}
POST /api/document/createWithTemplate
Use this endpoint to generate a PDF from a template using the supplied replacement values.
Body parameter
templateName: string
values: string
Parameters
Parameter | In | Type | Required | Description |
---|---|---|---|---|
body | body | object | false | No description |
» templateName | body | string | true | The name of the template to be used for generating the document |
» values | body | string | true | The key/value pair of replacement values for the placeholders defined in the template |
Note: the following are special items that can be passed in the values dictionary.
ndc
value will be used to determine the drug details for the patient support pages (rxData will be ignored)rxData
value will be parsed and used to lookup an NDC for the drug details on the patient support pagesquantity
value will be used for pricing on the savings cardcopayCard
if supplied, will override the Co-Pay Coupon setting on the template (expected values: "true" or "false")savingsCard
if supplied, will override the Savings Card setting on the template (expected values: "true" or "false")patientEducation
if supplied, will override the Patient Education setting on the template (expected values: "true" or "false")
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | PDF file stream | None |
Using Template Name
Code samples
POST https://www.dischargerx.com/api/document/processTemplate HTTP/1.1
Host: www.dischargerx.com
Content-Type: multipart/form-data
const string inFilePath = @"YourPDF.pdf";
const string outFilePath = @"OutputFile.pdf";
const string templateName = "TemplateName";
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://www.dischargerx.com/");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "Token");
var form = new MultipartFormDataContent();
using (var file = File.OpenRead(inFilePath))
{
var fileContent = new StreamContent(file);
fileContent.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
form.Add(fileContent, "file", Path.GetFileName(inFilePath));
form.Add(new StringContent(templateName), "templateName");
var response = await client.PostAsync("/api/document/processTemplate", form);
using (var writer = File.Open(outFilePath, FileMode.Create))
{
await (await response.Content.ReadAsStreamAsync()).CopyToAsync(writer);
}
}
}
POST /api/document/processTemplate
Secures a PDF with a template defined on the web. Use the template name to identify the template.
Body parameter
file: string
templateName: string
protectSettings: string
Parameters
Parameter | In | Type | Required | Description |
---|---|---|---|---|
body | body | object | false | No description |
» file | body | string(binary) | true | The source document |
» templateName | body | string | true | The template name |
» protectSettings | body | string | false | The digital protection settings JSON to be applied to the document (see ProtectSettings under Models) |
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | PDF file stream | None |
400 | Bad Request | Template not found | None |
Using Template JSON
Code samples
POST https://www.dischargerx.com/api/document/processJson HTTP/1.1
Host: www.dischargerx.com
Content-Type: multipart/form-data
const string inFilePath = @"InputFile.pdf";
const string outFilePath = @"OutputFile.pdf";
const string templateJson = @"{
""document"": {
""width"": 816,
""height"": 1056,
""xps"": null,
""printOnBack"": false,
""whiteFix"": false,
""repeatSecurity"": false,
""authMark"": null,
""duplexMode"": null,
""tray"": null,
""documentLevelSerialization"": false
},
""pages"": [
{
""captureRegions"": [],
""securityFeatures"": [
{
""id"": 1545083991962,
""x"": 258,
""y"": 478,
""width"": 300,
""height"": 100,
""type"": ""textbox"",
""text"": ""ProcessJson"",
""fontName"": ""Helvetica"",
""fontSize"": 12,
""lineSpacing"": 0,
""transform"": 0,
""color"": {
""r"": 240,
""g"": 11,
""b"": 11,
""a"": 1
},
""backgroundColor"": {
""r"": 255,
""g"": 255,
""b"": 255,
""a"": 1
},
""border"": {
""size"": 0,
""color"": {
""r"": 0,
""g"": 0,
""b"": 0,
""a"": 1
}
},
""rotationAngle"": 0,
""placement"": 0,
""scale"": 100,
""autoScale"": false,
""horizontalAlignment"": 0
}
]
}
],
""ui"": {
""currentPageIndex"": 0,
""selectedIndex"": 0,
""dirty"": true,
""saving"": false,
""culture"": {
""languageCode"": ""en"",
""countryCode"": ""US""
},
""documentName"": """",
""workflow"": ""template"",
""siteType"": ""docrity"",
""lastDownTarget"": """",
""mode"": ""design"",
""hoverIndex"": -1
},
""protectSettings"": null
}";
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://www.dischargerx.com");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "Token");
var form = new MultipartFormDataContent();
using (var file = File.OpenRead(inFilePath))
{
var fileContent = new StreamContent(file);
fileContent.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
form.Add(fileContent, "file", Path.GetFileName(inFilePath));
form.Add(new StringContent(templateJson), "templateJson");
var response = await client.PostAsync("/api/document/processJson", form);
using (var writer = File.Open(outFilePath, FileMode.Create))
{
await (await response.Content.ReadAsStreamAsync()).CopyToAsync(writer);
}
}
}
POST /api/document/processJson
Secures a PDF with a security profile JSON configuration.
Body parameter
file: string
templateJson: string
protectSettings: string
Parameters
Parameter | In | Type | Required | Description |
---|---|---|---|---|
body | body | object | false | No description |
» file | body | string(binary) | true | The source document |
» templateJson | body | string | true | The template JSON |
» protectSettings | body | string | false | The digital protection settings JSON to be applied to the document (see ProtectSettings under Models) |
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | PDF file stream | None |
400 | Bad Request | Invalid template JSON | None |
Download captured document
Code samples
GET https://www.dischargerx.com/api/document/download/{id} HTTP/1.1
Host: www.dischargerx.com
const string outFilePath = @"Download.pdf";
const string serialNumber = "SAMPLESERIALNO";
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://www.dischargerx.com");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "Token");
var response = await client.GetAsync($"/api/document/download/{serialNumber}");
using (var writer = File.Open(outFilePath, FileMode.Create))
{
await (await response.Content.ReadAsStreamAsync()).CopyToAsync(writer);
}
}
GET /document/download/{id}
Downloads a captured document if it exists.
Parameters
Parameter | In | Type | Required | Description |
---|---|---|---|---|
id | path | string | true | The document serial number |
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | PDF file stream | None |
400 | Bad Request | Document not found | None |
Document Logs
Retrieve document log information
Get document log records
Code samples
GET https://www.dischargerx.com/api/documentlogs/ HTTP/1.1
Host: www.dischargerx.com
Accept: application/json
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://www.dischargerx.com");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "Token");
var response = await client.GetAsync("/api/documentlogs");
var logs = await response.Content.ReadAsStringAsync();
Console.WriteLine(logs);
}
GET /api/documentlogs/
Gets a list of document log records. The list is sorted by the date the record was created, with the most recently created records at the top.
Parameters
Parameter | In | Type | Required | Description |
---|---|---|---|---|
pageSize | query | integer | false | The number of records per page (defaults to 100) |
pageNumber | query | integer | false | The page of records to be returned |
Example responses
[
{
"id": "string",
"serialNumber": "string",
"companyId": "string",
"pageCount": 0,
"userName": "string",
"printTime": "string",
"printTimeLocal": "string",
"documentName": "string",
"hasXps": 0,
"dataCapture": "string",
"authMarkCapture": "string"
}
]
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | A list of document log records | Inline |
Response Schema
Status Code 200
Name | Type | Required | Description |
---|---|---|---|
anonymous | [AuditRecord] | false | No description |
» id | string | false | The unique id of the audit record |
» serialNumber | string | false | The document serial number |
» companyId | string | false | The company id |
» pageCount | integer | false | The page count of the document |
» userName | string | false | The user name of the user who secured the document |
» printTime | string | false | The time the document was secured |
» printTimeLocal | string | false | The local time when the document was secured |
» documentName | string | false | The document name |
» hasXps | integer | false | A value indicating if the document was captured. If 1, the document was captured |
» dataCapture | string | false | A JSON object of the captured data |
» authMarkCapture | string | false | A JSON object of the captured data for AuthMark (may be hashed values) |
Get a document log record
Code samples
GET https://www.dischargerx.com/api/documentlogs/{id} HTTP/1.1
Host: www.dischargerx.com
Accept: application/json
const string serialNumber = "SAMPLESERIALNO";
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://www.dischargerx.com");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "Token");
var response = await client.GetAsync($"/api/documentlogs/{serialNumber}");
var log = await response.Content.ReadAsStringAsync();
Console.WriteLine(log);
}
GET /api/documentlogs/{id}
Gets a document log record for a given serial number.
Parameters
Parameter | In | Type | Required | Description |
---|---|---|---|---|
id | path | string | true | The document serial number |
Example responses
{
"auditRecord": {
"id": "string",
"serialNumber": "string",
"companyId": "string",
"pageCount": 0,
"userName": "string",
"printTime": "string",
"printTimeLocal": "string",
"documentName": "string",
"hasXps": 0,
"dataCapture": "string",
"authMarkCapture": "string"
},
"documentLink": "string",
"activity": [
{
"id": "string",
"type": 0,
"eventDateUtc": "string",
"companyId": "string",
"userId": "string",
"serialNumber": "string",
"ipAddress": "string"
}
]
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | A document log record plus blockchain entry details, if any. Also includes portal activity details, if any. | DocumentLog |
400 | Bad Request | Log record not found | None |
Portal Events
Retrieve portal event information
Get portal event records for a company
Code samples
GET https://www.dischargerx.com/api/portalevents HTTP/1.1
Host: www.dischargerx.com
Accept: application/json
GET /api/portalevents
Gets portal event records for the user's company
Parameters
Parameter | In | Type | Required | Description |
---|---|---|---|---|
pagenumber | query | integer | false | The page number |
pagesize | query | integer | false | The page size |
Example responses
[
{
"id": "string",
"type": 0,
"eventDateUtc": "string",
"companyId": "string",
"userId": "string",
"serialNumber": "string",
"ipAddress": "string"
}
]
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | A collection of portal events for the document. | Inline |
Response Schema
Status Code 200
Name | Type | Required | Description |
---|---|---|---|
anonymous | [PortalEvent] | false | No description |
» id | string | false | The event's unique id |
» type | integer | false | The event type |
» eventDateUtc | string | false | The event date in utc |
» companyId | string | false | The company id |
» userId | string | false | The user id |
» serialNumber | string | false | The document serial number |
» ipAddress | string | false | The IP address associated with the event |
Get portal event records for a document
Code samples
GET https://www.dischargerx.com/api/portalevents/serialnumber/{serialNumber} HTTP/1.1
Host: www.dischargerx.com
Accept: application/json
GET /api/portalevents/serialnumber/{serialNumber}
Gets portal event records given the serial number associated with it.
Parameters
Parameter | In | Type | Required | Description |
---|---|---|---|---|
serialNumber | path | string | true | The document serial number |
Example responses
[
{
"id": "string",
"type": 0,
"eventDateUtc": "string",
"companyId": "string",
"userId": "string",
"serialNumber": "string",
"ipAddress": "string"
}
]
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | A collection of portal events for the document. | Inline |
Response Schema
Status Code 200
Name | Type | Required | Description |
---|---|---|---|
anonymous | [PortalEvent] | false | No description |
» id | string | false | The event's unique id |
» type | integer | false | The event type |
» eventDateUtc | string | false | The event date in utc |
» companyId | string | false | The company id |
» userId | string | false | The user id |
» serialNumber | string | false | The document serial number |
» ipAddress | string | false | The IP address associated with the event |
Products
Serialize product information
Create a serialized product record
Code samples
POST https://www.dischargerx.com/api/products HTTP/1.1
Host: www.dischargerx.com
Content-Type: application/x-www-form-urlencoded
Accept: application/json
POST /products
Create a serialized product record of key/value pairs
Body parameter
record: string
Parameters
Parameter | In | Type | Required | Description |
---|---|---|---|---|
body | body | object | false | No description |
» record | body | string | true | The digital protection settings JSON to be applied to the document (see ProductRequest under Models) |
Example responses
{
"serialNumber": "string",
"url": "string"
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | Auth portal information | Inline |
Schemas
DocumentLog
{
"auditRecord": {
"id": "string",
"serialNumber": "string",
"companyId": "string",
"pageCount": 0,
"userName": "string",
"printTime": "string",
"printTimeLocal": "string",
"documentName": "string",
"hasXps": 0,
"dataCapture": "string",
"authMarkCapture": "string"
},
"documentLink": "string",
"activity": [
{
"id": "string",
"type": 0,
"eventDateUtc": "string",
"companyId": "string",
"userId": "string",
"serialNumber": "string",
"ipAddress": "string"
}
]
}
Properties
Name | Type | Required | Description |
---|---|---|---|
auditRecord | AuditRecord | false | No description |
documentLink | string | false | A URL for downloading the captured document |
activity | [PortalEvent] | false | Represents authentication portal events associated with the document |
AuditRecord
{
"id": "string",
"serialNumber": "string",
"companyId": "string",
"pageCount": 0,
"userName": "string",
"printTime": "string",
"printTimeLocal": "string",
"documentName": "string",
"hasXps": 0,
"dataCapture": "string",
"authMarkCapture": "string"
}
Properties
Name | Type | Required | Description |
---|---|---|---|
id | string | false | The unique id of the audit record |
serialNumber | string | false | The document serial number |
companyId | string | false | The company id |
pageCount | integer | false | The page count of the document |
userName | string | false | The user name of the user who secured the document |
printTime | string | false | The time the document was secured |
printTimeLocal | string | false | The local time when the document was secured |
documentName | string | false | The document name |
hasXps | integer | false | A value indicating if the document was captured. If 1, the document was captured |
dataCapture | string | false | A JSON object of the captured data |
authMarkCapture | string | false | A JSON object of the captured data for AuthMark (may be hashed values) |
PortalEvent
{
"id": "string",
"type": 0,
"eventDateUtc": "string",
"companyId": "string",
"userId": "string",
"serialNumber": "string",
"ipAddress": "string"
}
Properties
Name | Type | Required | Description |
---|---|---|---|
id | string | false | The event's unique id |
type | integer | false | The event type |
eventDateUtc | string | false | The event date in utc |
companyId | string | false | The company id |
userId | string | false | The user id |
serialNumber | string | false | The document serial number |
ipAddress | string | false | The IP address associated with the event |
ProductRequest
{
"property1": "string",
"property2": "string"
}
Properties
Name | Type | Required | Description |
---|---|---|---|
additionalProperties | string | false | No description |
ProtectSettings
{
"method": {
"const": 0,
"description": "Rc440"
},
"annotations": false,
"extraction": false,
"accessibility": false,
"assembly": false,
"modify": false,
"formsFill": false,
"print": false,
"encryptMedia": false,
"highQualityPrint": false,
"enhancedPasswordValidation": false,
"ownerPassword": "string",
"userPassword": "string"
}
Properties
Name | Type | Required | Description |
---|---|---|---|
method | integer | false | The encryption method |
annotations | boolean | false | A flag indicating whether to enable annotations |
extraction | boolean | false | A flag inidicating whether to enable extraction |
accessibility | boolean | false | A flag inidicating whether to enable accessibility |
assembly | boolean | false | A flag inidicating whether to enable document assembly |
modify | boolean | false | A flag inidicating whether to enable document modification |
formsFill | boolean | false | A flag inidicating whether to enable forms fill |
boolean | false | A flag inidicating whether to enable printing | |
encryptMedia | boolean | false | A flag inidicating whether to encrypt media |
highQualityPrint | boolean | false | A flag inidicating whether to enable high-quality printing |
enhancedPasswordValidation | boolean | false | A a flag inidicating whether to enable enhanced password validation (only applies to AES encryption) |
ownerPassword | string | false | The owner password |
userPassword | string | false | The user password |
SecurityTemplate
{
"id": "string",
"name": "string",
}
Properties
Name | Type | Required | Description |
---|---|---|---|
» id | string | false | The unique id of the security template |
» name | string | false | The security template name |