> For the complete documentation index, see [llms.txt](https://docs.thewalletcrew.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.thewalletcrew.io/developers-guides/fr/integration-guides/scan-api.md).

# API de scan

Enregistrer les scans de codes-barres et de codes QR avec l'API The Wallet Crew Scan pour valider les Cartes et déclencher des événements en aval tels que l'utilisation ou la présence.

L’API Scan enregistre un scan de code-barres ou de QR, puis le corrèle à une carte. Cela crée un signal fiable « en magasin / sur site » que les systèmes en aval peuvent utiliser pour les flux d’échange, le suivi de présence ou l’automatisation CRM. Un scan ne modifie pas la carte. La plateforme enregistre un `Carte:Scannée` événement, que les systèmes en aval et les automatisations peuvent utiliser.

<details>

<summary><strong>Exemples concrets</strong></summary>

* **Fidélité en magasin**: enregistrez un scan à la caisse pour déclencher une automatisation post-visite.
* **Entrée à l’événement**: enregistrez des scans aux portiques pour suivre la présence et empêcher la réutilisation.
* **Utilisation du bon**: enregistrez des scans pour marquer une offre comme consommée.

</details>

## Quand l’API Scan est nécessaire

Le matériel de code-barres/QR peut lire la valeur affichée sur une carte. L’API Scan est l’élément qui rend ce scan exploitable dans The Wallet Crew.

{% hint style="info" %}
L’API Scan ne remplace pas la logique de validation opérationnelle. Elle fournit un enregistrement de scan et une corrélation. Les règles d’utilisation, l’anti-fraude et la consommation des avantages dépendent du flux de travail choisi.
{% endhint %}

## Point de terminaison

L’API Scan est disponible via cette opération à portée locataire :

## Record a pass scan

> Finds the pass whose barcode value equals \`data\` (the most recently updated wins) and records a \`Pass:Scanned\` event with the data and type, which automations can react to. The pass is not changed. Requires \`tenant.scan:scan\`.

```json
{"openapi":"3.1.1","info":{"title":"The Wallet Crew internal API","version":"v1"},"tags":[{"name":"Scan"}],"servers":[{"url":"https://api.thewalletcrew.io","description":"Production Server"},{"url":"https://api-qa.thewalletcrew.io","description":"Staging Server"}],"security":[{"admin-bearer":["tenant.scan:scan"]},{"apiKey":[]}],"components":{"securitySchemes":{"admin-bearer":{"type":"oauth2","flows":{"implicit":{"authorizationUrl":"https://auth.neostore.cloud/authorize?audience=https://app.neostore.cloud/api/","scopes":{}}}},"apiKey":{"type":"apiKey","name":"X-API-KEY","in":"header"}},"schemas":{"AddScanRequest":{"required":["data","type"],"type":"object","properties":{"data":{"maxLength":2048,"minLength":3,"type":"string","description":"The decoded content, exactly as read. It must equal, character for character, one of the barcode\nvalues rendered on a pass (trimmed)."},"type":{"description":"How `data` was captured. Recorded on the scan event as `scannedType`, in PascalCase (for\nexample `QRCode` for `qrcode`).","$ref":"#/components/schemas/TypeEnum"}},"additionalProperties":false,"description":"A value read from a pass by a scanner, a camera or a keyboard."},"TypeEnum":{"enum":["manual","text","qrcode","pdf417","aztec","code128","code39","codabar","ean8","ean13","itf14","upca","datamatrix","nfc"],"type":"string","description":"How the value was captured. Recorded on the scan event only; it does not affect matching."},"AddScanResponse":{"required":["passId"],"type":"object","properties":{"passId":{"type":"string","description":"The pass carrying the scanned value. When several passes carry it, the most recently updated one."}},"additionalProperties":false,"description":"The pass the scanned value resolved to."},"ProblemDetails":{"type":"object","properties":{"type":{"type":["null","string"]},"title":{"type":["null","string"]},"status":{"type":["null","integer"],"format":"int32"},"detail":{"type":["null","string"]},"instance":{"type":["null","string"]}},"additionalProperties":{}},"HttpValidationProblemDetails":{"type":"object","allOf":[{"$ref":"#/components/schemas/ProblemDetails"}],"properties":{"errors":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}}},"additionalProperties":{}}}},"paths":{"/api/{tenantId}/scans":{"post":{"tags":["Scan"],"summary":"Record a pass scan","description":"Finds the pass whose barcode value equals `data` (the most recently updated wins) and records a `Pass:Scanned` event with the data and type, which automations can react to. The pass is not changed. Requires `tenant.scan:scan`.","parameters":[{"name":"tenantId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"description":"The scanned value and how it was captured.","content":{"application/json":{"schema":{"description":"A value read from a pass by a scanner, a camera or a keyboard.","$ref":"#/components/schemas/AddScanRequest"}},"text/json":{"schema":{"description":"A value read from a pass by a scanner, a camera or a keyboard.","$ref":"#/components/schemas/AddScanRequest"}},"application/*+json":{"schema":{"description":"A value read from a pass by a scanner, a camera or a keyboard.","$ref":"#/components/schemas/AddScanRequest"}}}},"responses":{"201":{"description":"Scan recorded; the body names the pass.","content":{"text/plain":{"schema":{"description":"The pass the scanned value resolved to.","$ref":"#/components/schemas/AddScanResponse"}},"application/json":{"schema":{"description":"The pass the scanned value resolved to.","$ref":"#/components/schemas/AddScanResponse"}},"text/json":{"schema":{"description":"The pass the scanned value resolved to.","$ref":"#/components/schemas/AddScanResponse"}}}},"400":{"description":"`data` is missing or outside 3 to 2048 characters, or `type` is missing or unknown.","content":{"text/plain":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ProblemDetails"},{"$ref":"#/components/schemas/HttpValidationProblemDetails"}]}},"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ProblemDetails"},{"$ref":"#/components/schemas/HttpValidationProblemDetails"}]}},"text/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ProblemDetails"},{"$ref":"#/components/schemas/HttpValidationProblemDetails"}]}}}},"401":{"description":"The caller is not authenticated.","content":{"application/problem+json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ProblemDetails"},{"$ref":"#/components/schemas/HttpValidationProblemDetails"}]}}}},"403":{"description":"The caller lacks the `tenant.scan:scan` scope, or the endpoint is not enabled for the tenant.","content":{"application/problem+json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ProblemDetails"},{"$ref":"#/components/schemas/HttpValidationProblemDetails"}]}}}},"404":{"description":"No pass carries the scanned value, or the tenant does not exist.","content":{"text/plain":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ProblemDetails"},{"$ref":"#/components/schemas/HttpValidationProblemDetails"}]}},"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ProblemDetails"},{"$ref":"#/components/schemas/HttpValidationProblemDetails"}]}},"text/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ProblemDetails"},{"$ref":"#/components/schemas/HttpValidationProblemDetails"}]}}}},"429":{"description":"Over 1200 requests per minute to this endpoint for the tenant (default limit); retry after `Retry-After`.","headers":{"Retry-After":{"description":"Seconds to wait before retrying. Sent when the limiter knows it.","schema":{"type":"integer"}}},"content":{"application/problem+json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ProblemDetails"},{"$ref":"#/components/schemas/HttpValidationProblemDetails"}]}}}}}}}}}
```

## Authentification et autorisation

Envoyez la clé API du locataire dans l’en-tête `X-API-KEY` . La clé doit avoir la portée `tenant.scan:scan` (affiché comme **Scans de cartes** dans l’éditeur de rôles). Appelez-la depuis un relais backend : la clé reste sur le serveur, et le relais peut ajouter l’enrichissement, la journalisation et les tentatives de nouvelle exécution.

L’application Carte Scanner est distincte : elle s’exécute comme un appareil enregistré. Cette API est destinée à vos propres scanners.

## Champs de la requête

L’opération accepte deux champs :

* `données`: la valeur brute décodée lue par le scanner. Elle doit comporter de 3 à 2048 caractères. Elle est comparée caractère par caractère à une valeur de code-barres affichée sur la carte (la valeur affichée est tronquée). Lorsque plusieurs cartes correspondent, c’est la carte la plus récemment mise à jour qui l’emporte.
* `type`: le type d’entrée du scan (symbologie). Il est enregistré avec le scan et n’affecte pas la correspondance.

### `type` valeurs

`type` est une énumération avec ces valeurs : `manuel` (quand le personnel saisit un code), `texte`, `code QR`, `pdf417`, `aztec`, `code128`, `code39`, `codabar`, `ean8`, `ean13`, `itf14`, `upca`, `datamatrix`, `nfc`.

Google Wallet ne prend en charge que certaines symbologies : `code39`, `codabar`, `ean8`, `ean13`, `itf14`, `upca` et `datamatrix` sont propres à Google Wallet.

{% hint style="warning" %}
`données` est traité comme un identifiant opaque. Le plus important est qu’il reste stable plutôt que lisible par l’humain. Les changements de format (trim, zéros en tête, séparateurs) sont des causes fréquentes d’échec de corrélation.
{% endhint %}

## Réponse

L’opération renvoie `201` et l’identifiant de la carte corrélée. Elle renvoie `404` lorsque la corrélation échoue. Le point de terminaison renvoie `429` au-dessus de sa limite de débit, 1200 requêtes par minute par défaut.

## Validez l’intégration

Une séquence de validation minimale est la suivante :

1. Utilisez une vraie carte émise par The Wallet Crew.
2. Scannez son code-barres/QR et capturez la valeur décodée.
3. Utilisez l’opération de l’API Scan avec `données` et `type`.
4. Confirmez une `201` réponse et une valeur non nulle `passId`.
5. Facultatif : confirmez que le signal en aval est reçu, par exemple un `Carte:Scannée` événement dans l’historique de la carte, ou `wallet_scanned` dans Bloomreach si ce connecteur est configuré.

## Dépannage

### `404 Introuvable`

La valeur scannée ne correspond à aucune carte.

Les causes courantes sont des différences de format de code-barres, des préfixes/suffixes manquants ou un décalage entre la configuration du code-barres du modèle et le décodage du scanner.

### `400 Requête incorrecte`

La charge utile n’a pas réussi la validation.

Les causes courantes sont des champs manquants, `données` une longueur hors limites, ou un `type`.

### `401 Non autorisé`

Les identifiants sont manquants ou invalides. Une clé valide sans `tenant.scan:scan` renvoie `403`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.thewalletcrew.io/developers-guides/fr/integration-guides/scan-api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
