API Documentation

REST Endpoints

SECURITY

We’ve added various security measures in order to secure our platform. 
Every request must have two headers:

SECURITY
account-id; // UUID format. This can be obtained from the Integrations screen.
secret; // Secret string. This can be obtained from the Integrations screen.

Creates new patient

Creates a new patient in order to be able to prescribe or refill medication.

Endpoint

POST /v2/patients/create

Request Fields

external_id Unique identifier for this patient in your system, which you can reference to create a prescription or refill.
first_name First name of the patient.
last_name Last name of the patient.
phone_number Patient’s contact phone number. Format is +1#######
birth_date Date of birth in YYYY-MM-DD format.

Response Fields

successBoolean whether the request was processed successfully or not.
messageShould have the request failed, this gives insight as to why.
errorCodeCode that describes what happened, if applicable (see below).

Possible Errors

DUPLICATE_IDExternal identifier already exists, most likely this means that the patient has already been created.
PATIENT_REQUIREDExternal identifier is a required field.
WRONG_DATE_FORMATBirth date was specified in the wrong format. Expected format is ‘yyyy-MM-dd’.
WRONG_PHONE_FORMATPhone Number was specified in the wrong format. Expected format is ‘+1####’.
Example Request
curl --location --request POST
'https://api.precisioncompoundingpharmacy.net/v2/patients/create' \
--header 'Content-Type: application/json' \
--header 'account-id: AAAAAAAAAAAAAAA' \
--header 'secret: XXXXXXXXXX' \
--data-raw '{
"external_id": "MM7",
"first_name": "Mike",
"last_name": "Montana",
"phone_number": "+13051234567",
"birth_date": "1978-05-12"
}'

GET PATIENTS

Queries the patients by one or more fields. At least one of the fields in the request parameters is required.

Endpoint

POST /v2//patients

Request Fields

external_idUnique identifier for this patient in your system.
first_nameFirst name of the patient.
last_nameLast name of the patient.

Response Fields

successBoolean whether the request was processed successfully or not.
messageShould have the request failed, this gives insight as to why.
errorCodeCode that describes what happened, if applicable (see below).
rowsArray containing all the patient objects that satisfy the search. This field will not be included if there are error(s) processing the request.
Example Request
curl --location --request POST
'https://api.precisioncompoundingpharmacy.net/v2/patients' \
--header 'Content-Type: application/json' \
--header 'account-id: AAAAAAAAAAAAAAA' \
--header 'secret: XXXXXXXXXX' \
--data-raw '{
"external_id": "MM7"
}'

GET PATIENTS BY ID

Queries a single patient by id. Where the id is external_id (String) or the record id in our system (UUID). The id must come as a parameter.

Endpoint

GET /v2/patients/:id

Request Fields

NONE
successBoolean whether the request was processed successfully or not.
messageShould have the request failed, this gives insight as to why.
errorCodeCode that describes what happened, if applicable (see below).
patientObject that satisfy the search. This field will not be included if there are
error(s) processing the request.
Example Request
curl --location GET 'https://api.precisioncompoundingpharmacy.net/v2/patients/MM7' \
--header 'account-id: AAAAAAAAAAAAAAA' \
--header 'secret: XXXXXXXXXX' \

CREATE NEW PRESCRIPTION

Creates a prescription for an existing patient. Nothing will be shipped until the prescription is ordered with the /order/create endpoint.

Endpoint

POST /v2/prescriptions/create

Request Fields

external_idERX identifier, obtained from Surescripts for example.
reference_idYour identifier for the order, this can be an internal identification generated by your system such as the order id.
external_patient_idYour own patient identifier, specified when the patient was created. This is required.
doctor_npiNational Provider Identifier of the doctor that prescribed the medication
to the patient. You can add this or the correct Doctor’s first_name and last_name.
doctor_first_nameFirst name of the doctor that prescribed the medication to the patient. Required when this is a controlled substance.
doctor_last_nameLast name of the doctor that prescribed the medication to the patient. Required when this is a controlled substance.
medication_idUUID of the medication prescribed, this code also specifies the
delivery form and strength of the medication. This code is provided by the pharmacy.
quantityAmount of the medication prescribed which depends on the delivery form of
the item. So for example, if the item_id is tablets, then this is the number of tablets to
include in the bottle, if the item_id is a foam, quantity is the number of mL units.
instructionsInstructions that will be included in the order for the patient to follow.
shipping_address1DEPRECATED Address where the medication will be shipped to.
shipping_address2DEPRECATED Address line 2 (apartment #, etc) where the
medication will be shipped to.
shipping_cityDEPRECATED City where the medication will be shipped to.
shipping_stateDEPRECATED State where the medication will be shipped to.
shipping_zip_codeDEPRECATED Zip code where the medication will be shipped to.
medicationsDEPRECATED Array containing the items and quantities in the prescription.
item_idDEPRECATED UUID of the item ordered, this code also specifies the delivery form and strength of the medication
quantityDEPRECATED Amount of the item ordered which depends on the delivery form of the item. So for example, if the item_id is tablets, then this is the number of tablets to include in the bottle, if the item_id is a foam, quantity is the number of mL units.
instructionsDEPRECATED Instructions that will be included in the order for the patient to follow.

Response Fields

successBoolean whether the request was processed successfully or not.
messageShould have the request failed, this gives insight as to why.
errorCodeCode that describes what happened, if applicable (see below).

Possible Errors

ID_REQUIREDEither the external_id or reference_id is required.
PATIENT_REQUIREDEither the patient_id or external_patient_id is required.
DOCTOR_REQUIREDWhen the prescription is a controlled substance, the doctor first/last name are required fields.
DUPLICATE_IDExternal identifier (or Reference identifier) already exists, most likely this means that the prescription has already been created.
PATIENT_NOT_FOUNDPatient does not exist. Please check patient_id or external_patient_id.
Example Request

curl --location --request POST
'https://api.precisioncompoundingpharmacy.net/v2/prescriptions/create' \
--header 'Content-Type: application/json' \
--header 'account-id: AAAAAAAAAAAAAAA' \
--header 'secret: XXXXXXXXXX' \
--data-raw '{
"external_id": "CCITEST01",
"external_patient_id": "MM7",
"doctor_npi": "555",
"doctor_first_name": "TEST",
"doctor_last_name": "TEST",
"medication_id": "507b02b6-05b7-4a17-a99d-aef196ec31c4",
"quantity": 5,
"instructions": "Drink water every two hours."
}'

ASSIGN ID TO PRESCRIPTION

Typically, we use the e-prescription id to reference the prescriptions. We understand that it may be easier to use your system’s identifier (such as an order id). For this, we allow the prescription id to be assigned your system id.

Endpoint

POST /v2/prescriptions/assign

Request Fields

external_idERX identifier, obtained from Surescripts for example.
reference_idYour identifier for the order, this can be an internal identification generated by your system such as the order id.

Response Fields

successBoolean whether the request was processed successfully or not.
messageShould have the request failed, this gives insight as to why.
errorCodeCode that describes what happened, if applicable (see below).

Possible Errors

EXTERNAL_ID_NOT_FOUNDPrescription does not exist. Please check external_id to see if the correct id was specified.
Example Request
curl --location --request POST
'https://api.precisioncompoundingpharmacy.net/v2/prescriptions/assign' \
--header 'Content-Type: application/json' \
--header 'account-id: AAAAAAAAAAAAAAA' \
--header 'secret: XXXXXXXXXX' \
--data-raw '{
"external_id": "1111222333",
"reference_id": "TEST1"
}'

CANCEL PRESCRIPTION

Cancels an existing prescription so that no more refills can be created. If there is a refill in process, it will be completed unless it is independently canceled.

Endpoint

POST /v2/prescriptions/cancel

Request Fields

prescription_external_idERX identifier, obtained from Surescripts for example, specified when the prescription was created. This or prescription_reference_id is required.
prescription_reference_idYour identifier for the order, this can be an internal identification generated by your system such as the order id. This or prescription_external_id is required.

Response Fields

successBoolean whether the request was processed successfully or not.
messageShould have the request failed, this gives insight as to why.
errorCodeCode that describes what happened, if applicable (see below).

Possible Errors

PRESCRIPTION_ID_REQUIREDEither the prescription_external_id or prescription_reference_id is required.
PRESCRIPTION_NOT_FOUNDPrescription does not exist. Please check prescription_reference_id or prescription_external_id.
ALREADY_CANCELEDThe prescription is already canceled, so there is nothing else to do.
Example Request
curl --location --request POST
'https://api.precisioncompoundingpharmacy.net/v2/prescriptions/cancel' \
--header 'Content-Type: application/json' \
--header 'account-id: AAAAAAAAAAAAAAA' \
--header 'secret: XXXXXXXXXX' \
--data-raw '{
"prescription_external_id": "CCITEST01"
}'

CREATE NEW FILL

Fills an existing prescription for a patient. This removes the “hold” status for the prescription(s) and prepares/ships 1 order of the prescription(s).

Endpoint

POST /v2/[re]fills/create

Request Fields

refill_external_idRefill identifier generated by your system.
refill_reference_idRefill identifier generated by your system.
packaging_idUUID of the packaging to use to ship the order.
shipping_address1Address where the order will be shipped to.
shipping_address2Address line 2 (apartment #, etc) where the order will be shipped to.
shipping_cityCity where the order will be shipped to.
shipping_stateState where the order will be shipped to.
shipping_zip_codeZip code where the order will be shipped to.
carrierName of the carrier preselected for the order packages. Options: “fedex” or “usps”.
shipping_methodIndicate the service type preselected for the carrier selected used for the order packages.

Options for FedEx (carrier = “fedex”):
> fedex_first_overnight
> fedex_priority_overnight
> fedex_standard_overnight
> fedex_2_day
> fedex_2_day_am
> fedex_express_saver

Options for USPS (carrier = “usps”):
> usps_first_class_mail_flat
> usps_first_class_mail_letter
> usps_first
> usps_parcel_select
> usps_priority
> usps_first_class_package_international_service
> usps_priority_mail_international
> usps_media_mail
> usps_first_class_mail_international
> usps_priority_mail_express_international
> usps_priority_express
prescriptions_external_idsArray of ERX identifiers, obtained from Surescripts for example, specified when the prescription was created. This or prescriptions_reference_ids is required.
prescriptions_reference_idsArray of your identifiers for the order, this can be an internal identification generated by your system such as the order id. This or prescriptions_external_ids is required.
item_idsArray of non-controlled items and quantities to include in the order.
item_idUUID of the item ordered. This code is provided by the pharmacy.
quantityAmount of the item ordered. The unit depends on the item_id provided by the pharmacy.
internal_notesNotes that are seen by the pharmacy only. This can be used to communicate anything about the order to the pharmacy, such as “this is a test do not fulfill”, etc.
prescription_external_idDEPRECATED ERX identifier, obtained from Surescripts for example, specified when the prescription was created. This or prescription_reference_id is required.
prescription_reference_idDEPRECATED Your identifier for the order, this can be an internal identification generated by your system such as the order id. This or prescription_external_id is required.

Response Fields

successBoolean whether the request was processed successfully or not.
messageShould have the request failed, this gives insight as to why.
errorCodeCode that describes what happened, if applicable (see below).

Possible Errors

PRESCRIPTION_ID_REQUIREDEither the prescription_external_id or prescription_reference_id is required.
REFILL_ID_REQUIREDThe refill_reference_id field is required.
PRESCRIPTION_NOT_FOUNDPrescription does not exist. Please check prescription_reference_id or prescription_external_id.
SHIPPING_ADDRESS_MISSINGPatient does not have a shipping address on file, it must be specified.
Example Request
curl --location --request POST
'https://api.precisioncompoundingpharmacy.net/refills/create' \
--header 'Content-Type: application/json' \
--header 'account-id: AAAAAAAAAAAAAAA' \
--header 'secret: XXXXXXXXXX' \
--data-raw '{
"prescriptions_external_ids": ["CCITEST01"],
"refill_external_id": "TEST11",
"shipping_address1": "123 First",
"shipping_address2": "",
"shipping_city": "City",
"shipping_state": "ST",
"shipping_zip_code": "12345"
}'

CANCEL FILL

Cancels an existing fill request so that it is not sent to the customer. Fills may only be canceled before they are shipped.

Endpoint

POST /v2/[re]fills/cancel

Request Fields

refill_reference_idRefill identifier generated by your system.

Response Fields

successBoolean whether the request was processed successfully or not.
messageShould have the request failed, this gives insight as to why.
errorCodeCode that describes what happened, if applicable (see below).

Possible Errors

REFILL_ID_REQUIREDThe refill_reference_id field is required.
REFILL_NOT_FOUNDThe fill does not exist. Please check the refill_reference_id field.
REFILL_ALREADY_SHIPPEDThe fill cannot be canceled as it has already shipped or had been delivered.
Example Request
curl --location --request POST
'https://api.precisioncompoundingpharmacy.net/v2/fills/cancel' \
--header 'Content-Type: application/json' \
--header 'account-id: AAAAAAAAAAAAAAA' \
--header 'secret: XXXXXXXXXX' \
--data-raw '{
"refill_reference_id": "CCITEST01"
}'

Webhooks

SECURITY

We’ve added various security measures in order to secure our platform. One of these measures is to digitally sign every request sent to the REST endpoints on your end. This will allow you to verify that the request really did come from our platform.
We do this using HMAC encryption plus a secret key which is supplied at registration time. This means that in order to verify the request, the body must be hashed using SHA-256 and then encoded with Base64.
All webhook requests are sent with a header called “x-hmac-hash” which contains the signed request. All parameters sent to your endpoint are encoded in JSON.

How this is verified is easier explained with code. Here we provide an example with Node:

SECURITY
account-id; // UUID format. This can be obtained from the Integrations screen.
secret; // Secret string. This can be obtained from the Integrations screen.

RECEIVED EVENT

This event or web hook is called when the pharmacy has received the e-Prescription from the doctor. It is in system for processing. This event is sent for prescriptions only.

Parameters

testIndicates whether if this is a test or real production transaction.
typeIdentifies the type of event being notified, this being “received”.
external_idTransaction identification that was sent to us (this is an id you use to reference the transaction) when creating the prescription.
reference_idTransaction identification that was sent to us (this is an id you use to reference the transaction) when creating the prescription.
patient_first_namePatient’s first name as written in the e-prescription sent by the doctor.
patient_last_namePatient’s last name as written in the e-prescription sent by the doctor.
patient_birth_datePatient’s date of birth. Format is YYYY-MM-DD.
doctor_npiNPI (National Provider Identifier) of the doctor that ordered the prescription.
doctor_first_nameFirst name of the doctor that ordered the prescription.
doctor_last_nameLast name of the doctor that ordered the prescription.
doctor_addressDoctor’s physical address registered in the e-prescription system.

WARNING EVENT

Queries the patients by one or more fields. At least one of the fields in the request parameters is required.
The reason for this warning event is included in the payload sent to the endpoint (see below).

Parameters

testIndicates whether if this is a test or real production transaction.
typeIdentifies the type of event being notified, this being “warning”.
event_forWhat type of transaction the warning is for. This can be “prescription” or “fill”.
prescription_external_idTransaction identification that was sent to us (this is an id you use to reference the transaction) when creating the prescription.
prescription_reference_idTransaction identification that was sent to us (this is an id you use to reference the transaction) when creating the prescription.
fill_external_idTransaction identification that was sent to us (this is an id you use to
reference the transaction) when creating the fill.
fill_reference_idTransaction identification that was sent to us (this is an id you use to
reference the transaction) when creating the fill.
first_fill_dateWhen the reason_code is 1140 (Controlled substance too soon), we will
send back the date that the prescription will be able to be filled.
reason_code
> 1010
> 1020
> 1030
> 1040
> 1050
> 1060
> 1070
> 1080
> 1090
> 1100
> 1110
> 1120
> 1130
> 1140
> 1150

> 1160
> 2010
Indicates the reason why the warning flag was raised for this order, these include:
> Quantity verification (for prescription)
> Drug verification (for prescription)
> Direction verification (for prescription)
> Patient shipping address verification (for fill)
> Patient allergies needed (for prescription)
> Patient name clarification (for prescription)
> Patient DOB clarification (for prescription)
> Drug interaction detected (for prescription)
> Duplicate prescription received (for prescription)
> Strength verification (for prescription)
> Dosage form verification (for prescription)
> Device verification (for prescription)
> Request shipping method (for fill)
> Controlled substance too soon (for prescription)
> Prescription requires code (for prescription)
> Fax not legible (for prescription)
> Problem delivering package (for fill)

SHIPPED EVENT

This event or web hook is called when the pharmacy has shipped the patient’s order. This includes the order’s tracking number. This event is sent for fills only.

Parameters

testIndicates whether if this is a test or real production transaction.
typeIdentifies the type of event being notified, this being “shipped”.
fill_external_idTransaction identification that was sent to us (this is an id you use to reference the transaction) when creating the fill.
fill_reference_idTransaction identification that was sent to us (this is an id you use to reference the transaction) when creating the fill.
prescription_external_idTransaction identification that was sent to us (this is an id you use to reference the transaction) when creating the prescription.
prescription_reference_idTransaction identification that was sent to us (this is an id you use to reference the transaction) when creating the prescription.
total_packagesTotal number of packages that this order is comprised of. When this is greater than 1, the order will be shipped in more than one physical package.
package_numberPackage number out of the total packages that the tracking number applies to.
carrierName of the carrier that was used to ship the order. That is FedEx, USPS or UPS.
tracking_numberTracking number for the specified package.

ESTIMATED DELIVERY EVENT

This event or web hook is called when the package has been delivered to the patient.

Parameters

testIndicates whether if this is a test or real production transaction.
typeIdentifies the type of event being notified, this being “estimate”.
fill_external_idTransaction identification that was sent to us (this is an id you use to reference the transaction) when creating the fill.
fill_reference_idTransaction identification that was sent to us (this is an id you use to reference the transaction) when creating the fill.
prescription_external_idTransaction identification that was sent to us (this is an id you use to reference the transaction) when creating the prescription.
prescription_reference_idTransaction identification that was sent to us (this is an id you use to reference the transaction) when creating the prescription.
total_packagesTotal number of packages that this order is comprised of. When this is greater than 1, the order will be shipped in more than one physical package.
package_numberPackage number out of the total packages that the tracking number applies to.
carrierName of the carrier that was used to ship the order. That is FedEx, USPS or UPS.
tracking_numberTracking number for the specified package.

DELIVERED EVENT

Typically, we use the e-prescription id to reference the prescriptions. We understand that it may be easier to use your system’s identifier (such as an order id). For this, we allow the prescription id to be assigned your system id.

Parameters

testIndicates whether if this is a test or real production transaction.
typeIdentifies the type of event being notified, this being “delivered”.
fill_external_idTransaction identification that was sent to us (this is an id you use to reference the transaction) when creating the fill.
fill_reference_idTransaction identification that was sent to us (this is an id you use to reference the transaction) when creating the fill.
prescription_external_idTransaction identification that was sent to us (this is an id you use to reference the transaction) when creating the prescription.
prescription_reference_idTransaction identification that was sent to us (this is an id you use to reference the transaction) when creating the prescription.