Reading and Writing Your App's Data

List, create, update and delete your Hint App's records across every practice that installed it, with your partner API key.

Audience: partners. This guide is for partners whose app keeps its data in Hint: models you declare on the app, and records the app writes for each practice that installs it. Inside Hint, your app's page and functions only ever see the current practice's records. Your own systems (a back office, a reporting job, an import script) can reach every practice's records through the Partner API, with your partner API key.

🚧

Preview

The records endpoints below ship with the next Partner API reference update. Until the reference pages appear, this guide is the description of record.

How the data is organized

  • Models belong to your app. Each has a schema of fields, some marked sensitive or function_only (kept from your app's page, not from you), and optionally a key: the fields a record is unique by within one practice. Manage them with List App Models and its sibling endpoints.
  • Records belong to one model and to one installation of your app, so to one practice. A record never moves between practices.
  • Installations are the practices that installed your app. List them, with each one's practice, with List Installations, filtered to your app's product.
flowchart LR
  Model[Model] --> Record[Record]
  Installation[Installation] --> Record
  Practice[Practice] --> Installation

Authenticate

Use your partner API key, the same one you use for every /api/partner/* call:

Authorization: Bearer <partner_api_key>

Never use a practice's access token here: these endpoints belong to the partner, and a practice key is refused. Every path starts with /api/partner/products/{product_id}/app, where product_id is your app's product. Another partner's product is a 404.

Sandbox and live never mix. A sandbox partner key sees only sandbox installations and their records; a live key sees only live ones.

List records

GET /api/partner/products/{product_id}/app/records?model={model_id} lists one model's records across every installing practice. Add installation={installation_id} to list one practice's records.

curl "https://api.hint.com/api/partner/products/ppro-ab12C345DeF6/app/records?model=amod-ab12C345DeF6&limit=100" \
  -H "Authorization: Bearer $HINT_API_KEY"
[
  {
    "id": "arec-ab12C345DeF6",
    "model": { "id": "amod-ab12C345DeF6", "name": "visit_photo" },
    "installation": {
      "id": "inst-ab12C345DeF6",
      "practice": { "id": "pra-ab12C345DeF6", "name": "Main Street Clinic" }
    },
    "data": {
      "external_id": "ph-1042",
      "caption": "Left forearm, follow-up",
      "taken_on": "2017-02-03",
      "status": "reviewed",
      "reviewer_note": "Healing well"
    },
    "sandbox": false,
    "created_at": "2017-02-05T06:23:00.000000-08:00",
    "updated_at": "2017-02-05T06:23:00.000000-08:00",
    "deleted_at": null
  }
]

The list takes the same query as your app's own data API:

ParameterUse
filter[field]=valueEquality on a declared field. filter[field][op]=value with op one of eq, in (comma-separated, at most 100 values), gt, gte, lt, lte. An undeclared field is a 400.
sortA declared field, created_at or updated_at; prefix - for descending. Defaults to created_at.
updated_at[gt]Only records changed since this time. Pair with include_deleted=true to see deletions when you poll.
include_deletedInclude deleted records.
limit, offsetPaging. limit defaults to 10 and is at most 100.

Responses carry X-Total-Count (every match) and X-Count (this page). Offset pages are not a snapshot, so de-duplicate by id when you page through a model that is changing.

GET /api/partner/products/{product_id}/app/records/{id} returns one record, deleted or not, with the patients it links to under links.

A record whose installation was removed still names that installation and its practice.

Nothing is masked

Every field comes back with its value, sensitive and function_only ones included. The model's schema says which fields are sensitive: mask them in any screen your staff use, and keep them out of logs. Every record you read is recorded in Hint's read audit under your partner account.

Write records

Each write touches one record, in one practice.

CallBodyResult
POST .../app/recordsmodel, installation, data, optional links201 with the record. A record with the same key already in that practice is a 409.
PATCH .../app/records/{id}data, optional links200. Only the fields data names change.
DELETE .../app/records/{id}none204. The record is soft-deleted: it can still be shown, and include_deleted=true lists it.

installation is required on create: it picks the practice the record belongs to, and it must be an installation of this app. data is checked against the model's schema, and a refused value is a 422 naming the field. function_only fields can be written here, as your app's functions can; only your app's page is kept from them. links replaces the patients a record links to, as [{ "linkable": { "id": "pat-..." } }]; each must be a patient of the record's practice.

A model's declared key is unique per practice. Creating a second record with the same key in that practice returns 409 with "message": "A record with this key already exists"; change the existing record with PATCH instead. The same key in another practice is another record.

curl -X POST "https://api.hint.com/api/partner/products/ppro-ab12C345DeF6/app/records" \
  -H "Authorization: Bearer $HINT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
        "model": "amod-ab12C345DeF6",
        "installation": "inst-ab12C345DeF6",
        "data": { "external_id": "ph-1042", "taken_on": "2017-02-03", "status": "pending" }
      }'

Writes are recorded in each record's history and in Hint's audit trail as made by your API key.

What stays inside the app

Batch writes, bulk creates and deleting by filter are available to your app's functions only. Files are uploaded by your app's page or functions; records return each file field as its file, with a short-lived download link.

Removed installations

An installation is removed when the practice uninstalls your app (the installation is deactivated) or when the installation is deleted. Its records stay, and you can still list and show them. Every write to them, and any create naming that installation, is a 409.


Did this page help you?