# Decode a YoPrint barcode

```http
POST https://secure.yoprint.com/v1/api/store/{team_slug}/decode_barcode
```

- API version: v1
- Operation ID: `v1_public_misc_decode_barcode`
- Section: Production › [Barcodes](https://developer.yoprint.com/reference/barcodes.md)
- Web page: https://developer.yoprint.com/reference/barcodes/v1-misc-decode-barcode/
- Authentication: `Authorization: Bearer YOUR_API_KEY`

Turns the text of a barcode or QR code printed by YoPrint on a work order, packing slip, label or purchase order into the record it points to: its type and id. Use it in a scanner app.

YoPrint codes look like `y9-0p-<kind>-<number>`, where kind is `ord` (sales order or quote), `po` (purchase order), `ship` (shipment), `job` (job) or `ta` (stock transfer). For a job or shipment, `parent` is its order.

## Permission

Any member of the team. It does not check whether you can view the record.

## Business rules

- `value` is required and must start with `y9-0p-`.

## Path parameters

- `team_slug` (string, required): Your team slug, shown as Team ID next to your API key in Profile. Example `your-team`.

## Request body

Content type `application/json`, required.

Fields:

- `value` (string, required): The scanned text, starting with `y9-0p-`. Matches `^y9-0p-`.

### Example request

```bash
curl -X POST 'https://secure.yoprint.com/v1/api/store/your-team/decode_barcode' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Accept: application/json' \
  -H 'X-Yoprint-Decimal-Format: exact-v1' \
  -H 'Content-Type: application/json' \
  -d '{
    "value": "y9-0p-job-1234"
  }'
```

## Response

`200` Successful response.

Fields:

- `data` (object, required)
  - `id` (string, required): The record's id.
  - `type` (string, required): One of: `"sales_order"`, `"quote"`, `"purchase_order"`, `"shipment"`, `"job"`, `"transfer_adjustment"`.
  - `object_type` (string, optional): Quotes only: `quote`.
  - `parent` (object, optional): Jobs and shipments: the order they belong to.
    - `id` (string, optional)
    - `object_type` (string, optional)
    - `type` (string, optional): One of: `"sales_order"`, `"quote"`.
- `status` (integer, required)
- `success` (boolean, required)

Example response:

```json
{
  "data": {
    "id": "K6iF8n29iwOZnj",
    "parent": {
      "id": "V4keXwwxMQyXw7",
      "object_type": "sales_order",
      "type": "sales_order"
    },
    "type": "job"
  },
  "status": 200,
  "success": true
}
```

## Errors

- `401` The API key is missing or wrong (`unauthenticated`).
- `403` You are not allowed to do this. `api_access_not_in_plan`: your team's plan doesn't include API access (Pro and above, with an active subscription or trial), so every request answers this until the team upgrades. When your role lacks the permission the operation needs, the body is only `{"message": "Insufficient Permission"}`. Other refusals use the error envelope, with `unauthorized` or `user_is_not_authorized`.
- `404` Not found. `page_not_found`: the team slug is unknown, you are not a member of the team, or an id in the path is not one of this team's. `code: null`, with a message that starts "No query results for": there is no record with that id.
  - When: The kind is unknown, or the record does not exist on this team or was deleted. The error has no code or message. Fix: Check you are using the right team. A deleted record can't be scanned.
- `422` The request was refused and changed nothing. `validation_failed` lists what to fix in `error.fields`; other codes name a business rule, explained in `error.message`. A few checks answer with only `{"message": "..."}`. An operation that calls another service (a payment provider, a carrier, an accounting app) can answer `connect_timeout` ("Please retry again") when that service does not answer in time: the change may or may not have happened there, so read the record back before you retry.
  - When: `value` is missing or does not start with `y9-0p-` (`validation_failed`; `error.fields` names the field). Fix: Send the scanned text exactly as read. It is not a YoPrint code otherwise.

## Notes

- The number in the code is not the id the API uses. Always decode it here instead of building ids yourself.
