---
title: "Export consultation to Link"
method: POST
path: "/workspaces/{workspaceId}/consultations/{consultationId}/link/export"
tags: ["link"]
---

# Export consultation to Link

`POST /workspaces/{workspaceId}/consultations/{consultationId}/link/export`

## Request

- Base URL: `https://vetnio.com/api/v2`
- URL: `https://vetnio.com/api/v2/workspaces/{workspaceId}/consultations/{consultationId}/link/export`
- Auth: HTTP bearer

Writes the consultation's structured clinical note (generated with a Link JSON template, see the resolve endpoint) into a Link journal entry.

- **First export**: pass `customerId` and `animalId`. A new entry is created with the Link template, at `locationId` or the integration's default location. Response `mode: created`.
- **Later exports**: the entry recorded on the consultation is updated in place and `customerId`/`animalId` are ignored. Response `mode: updated`.
- **Existing entry**: pass `targetEntryId` (from the compatible-entries endpoint) plus `customerId` and `animalId` to write into an entry created in Link.
- **Reassign**: `reassign: true` with a new `customerId`/`animalId` creates a fresh entry; the old entry is left untouched in Link.

When updating, text fields are append-only: only lines added since Vetnio's last successful export to that entry are appended after a blank line, so text the vet wrote in Link is kept and retries do not duplicate text. Select, checkbox and result fields are overwritten; fields missing from the note are not touched. Locked, deleted or cancelled entries cannot be updated (`400`). If Link rejects any field during an update, the request fails with `500`; fields Link accepted may already be saved, but Vetnio does not record the export, so a retry does not duplicate text. When creating, rejected fields are only reported in `fieldWrites.create.errors`.

## Path parameters

- `workspaceId` string, required: Identifier of the clinic (workspace), as returned by `GET /workspaces`. The key's user must be a member of the clinic, or an admin of the organization it belongs to.
- `consultationId` string, required: Identifier of the Vetnio consultation (UUID) whose structured clinical note is exported to, or matched against, Link.

## Request body

- object
  - `customerId` integer: Link customer who owns the animal. Required on the first export, with `reassign: true`, and with `targetEntryId`; ignored when the consultation's existing entry is updated in place.
  - `animalId` integer: Link animal whose journal receives the entry. Required in the same cases as `customerId`, and must belong to that customer.
  - `locationId` integer: Link location (clinic site) for a newly created entry. Defaults to the integration's `defaultLocationId`; the request fails with `400` when neither is set. Ignored for updates.
  - `reassign` boolean: Set to `true` to create a new entry for `customerId`/`animalId` even though the consultation was already exported. The previous entry is left as it is in Link and the consultation is re-pointed to the new one. Defaults to `false`.
  - `targetEntryId` integer: Id of an existing Link entry to write into instead of creating one, typically from the compatible-entries endpoint. Takes precedence over the entry already recorded on the consultation. The entry must belong to `customerId` and `animalId`, be editable, and use a compatible template.

## Response `200`

Link entry id, journal id, deep-link URL, mode, and per-field write results.

- LinkExportResult: Outcome of exporting a consultation's structured clinical note to a Link journal entry.
  - `linkEntryId` integer, required: Id of the Link journal entry that was created or updated. Stored on the consultation so later exports update the same entry.
  - `linkJournalId` integer, required: Id of the animal's Link journal (medical record) that holds the entry.
  - `entryUrl` string, required: Deep link that opens the entry in Link's web app.
  - `mode` 'created' | 'updated', required: What the export did: - `created` — a new journal entry was created (first export, or `reassign: true`). - `updated` — an existing entry was updated in place (the consultation's previously exported entry, or `targetEntryId`).
  - `fieldWrites` object, required: Per-field results Link reported for the export.
    - `create` object, required: Results of the main write. Despite the name, this also holds the results of an in-place update (`mode: updated`); it is empty when an update had nothing new to write.
      - `applied` integer[], required: Ids of the fields Link reports as written.
      - `skipped` object[], required: Fields Link did not write and did not reject.
        - `key` union, required: The field the result refers to, as Link reports it: the template field id when an entry is created, the entry field id when one is updated.
          - string
          - number
        - `reason` string, required: Link's explanation of why the field was not written, passed through unchanged.
      - `errors` object[], required: Fields Link rejected. When an entry is created, rejected fields are reported here and the export still succeeds; when an existing entry is updated, any rejection fails the request instead.
        - `key` union, required: The field the result refers to, as Link reports it: the template field id when an entry is created, the entry field id when one is updated.
          - string
          - number
        - `messages` string[], required: Validation messages from Link, passed through unchanged.
    - `internalSamples` object: Results of the follow-up write that fills lab/measurement result rows on a newly created entry. Absent when there were none, and always absent for `mode: updated` (those values are part of `create`).
      - `applied` integer[], required: Ids of the fields Link reports as written.
      - `skipped` object[], required: Fields Link did not write and did not reject.
        - `key` union, required: The field the result refers to, as Link reports it: the template field id when an entry is created, the entry field id when one is updated.
          - string
          - number
        - `reason` string, required: Link's explanation of why the field was not written, passed through unchanged.
      - `errors` object[], required: Fields Link rejected. When an entry is created, rejected fields are reported here and the export still succeeds; when an existing entry is updated, any rejection fails the request instead.
        - `key` union, required: The field the result refers to, as Link reports it: the template field id when an entry is created, the entry field id when one is updated.
          - string
          - number
        - `messages` string[], required: Validation messages from Link, passed through unchanged.

## Other responses

- `400`: Invalid input data
- `401`: Authorization not provided
- `403`: Insufficient access
- `500`: Internal server error

---

[API](https://skmtc.dev/vetnio/apis/vetnio-api.md) - [All operations](https://skmtc.dev/vetnio/apis/vetnio-api/llms.txt) - [OpenAPI document](https://skmtc.dev/vetnio/apis/vetnio-api/revisions/d004afd5617d?raw)
