> ## Documentation Index
> Fetch the complete documentation index at: https://docs.thingidentity.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Resolve a compressed GS1 Digital Link

> Resolve a GS1 Digital Link compressed in the EPC binary encoding, as eh (hexadecimal) or ex (Base64url).

A compressed GS1 Digital Link carries the GTIN, its serial number and other Application Identifiers in one short
path segment, in the EPC binary encoding of the
[GS1 EPC Tag Data Standard](https://ref.gs1.org/standards/tds/) 2.3. The
[code generator](/api-reference/endpoints/generate-code#compression) writes these links when `compression` is
`EPC_HEX` or `EPC_BASE64`.

The resolver decodes the segment into the uncompressed link and resolves it exactly like
[`GET /01/{gtin}`](/api-reference/resolver/resolve-gtin): same query parameters, headers, redirects, linkset and
status codes. For example, these three requests get the same answer:

```
/eh30164596F40C0E5CBE991A83
/exMBZFlvQMDly-mRqD
/01/09528765123457/21/123456789123
```

And these two, as a DSGTIN+ carries a date:

```
/ehFB342CDE795211411234538566CB0AFC4
/01/79521141123453/21/32a%2Fb?17=220630
```

## Path parameters

<ParamField path="compressedLink" type="string" required>
  `eh` followed by the EPC in hexadecimal (case-insensitive), or `ex` followed
  by the EPC in Base64url (`A-Z`, `a-z`, `0-9`, `-`, `_`, no padding). 3 to 1024
  characters in total. A trailing slash is ignored.
</ParamField>

## Supported EPC schemes

Every scheme carries a GTIN and a serial number (AI `21`).

| Header | Scheme                     | Also carries                                                                                   |
| ------ | -------------------------- | ---------------------------------------------------------------------------------------------- |
| `30`   | SGTIN-96                   | Numeric serial number, without leading zeros.                                                  |
| `36`   | SGTIN-198                  | Serial number of up to 20 characters.                                                          |
| `F7`   | SGTIN+                     | Other Application Identifiers.                                                                 |
| `FB`   | DSGTIN+                    | A date (AI `11`, `13`, `15`, `16`, `17`, `7006` or `7007`), and other Application Identifiers. |
| `FC`   | DSGTIN++ (with a hostname) | The same as `FB`.                                                                              |
| `FD`   | SGTIN++ (with a hostname)  | The same as `F7`.                                                                              |

The filter value and the hostname encoded in the EPC are ignored: the link resolves on the host it was scanned
on.

## How the link is decoded

* The consumer product variant (`22`), lot (`10`), serial (`21`) and `235` become the key qualifiers of the
  uncompressed link, in that order. They are what the linkset `anchor` shows and what a redirect to the brand's
  custom domain uses.
* Every other Application Identifier, the date of a DSGTIN+ included, becomes a query parameter placed before the
  scan's own query string.

## Responses

The same as [`GET /01/{gtin}`](/api-reference/resolver/resolve-gtin#responses). A segment that does not decode is
`400 Bad Request` with `INVALID_GS1_DIGITAL_LINK`:

* a character outside the alphabet, or a segment shorter than 3 or longer than 1024 characters,
* a header other than those listed above,
* an Application Identifier the EPC encoding does not know, or data left after the last one (other than
  zero padding),
* the same Application Identifier twice with different values,
* a decoded link that is not a valid GS1 Digital Link, for example a GTIN with a wrong check digit.

<RequestExample>
  ```bash Hexadecimal theme={null}
  curl -i https://thingidentity.com/ehFB342CDE795211411234538566CB0AFC4
  ```

  ```bash Base64url theme={null}
  curl -i https://thingidentity.com/exMBZFlvQMDly-mRqD
  ```

  ```bash Linkset theme={null}
  curl -H "Accept: application/linkset+json" https://thingidentity.com/eh30164596F40C0E5CBE991A83
  ```
</RequestExample>

<ResponseExample>
  ```http 307 theme={null}
  HTTP/2 307
  location: /en-us/acme/level-bubbles/product-information-page?17=220630&21=32a%2Fb
  cache-control: public, s-maxage=600, stale-while-revalidate=600
  access-control-allow-origin: *
  ```

  ```json 400 theme={null}
  { "status": 400, "error": "INVALID_GS1_DIGITAL_LINK" }
  ```
</ResponseExample>
