{"openapi":"3.1.0","info":{"title":"PatoCard API","version":"1.0.0","description":"Loyalty cards in Apple Wallet and Google Wallet. One key = one business: each call's business comes from the key. Field names, paths and error codes are in Spanish (they're the contract); `mensaje` in errors is in Spanish too, so program against `codigo`. Docs: https://patocard.com/en/docs/api"},"servers":[{"url":"https://patocard.com/api/v1"}],"security":[{"llave":[]}],"components":{"securitySchemes":{"llave":{"type":"http","scheme":"bearer","description":"A `pc_live_…` key created in the panel under Ajustes → Integraciones (Settings → Integrations)."}}},"tags":[{"name":"Read","description":"A read-only key is enough."},{"name":"Write","description":"They need a read-write key."}],"paths":{"/yo":{"get":{"operationId":"yo","summary":"Test your key","description":"Which business and which key these are. It's the first call when integrating: if it answers, the key and the plan are fine.","tags":["Read"],"x-alcance":"lectura","responses":{"200":{"description":"The business and the key (never the full key).","content":{"application/json":{"example":{"negocio":{"nombre":"Ila Hot Room","slug":"ila"},"llave":{"nombre":"Ollynk","prefijo":"pc_live_hLBzJM","alcance":"escritura"}}}}},"401":{"description":"`no_autenticado`: No key, malformed, nonexistent or revoked.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"403":{"description":"`plan_no_incluye`: The business's plan doesn't include the REST API.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"429":{"description":"`limite`: too many calls with this key; `Retry-After` says how long to wait.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}}}}},"/programas":{"get":{"operationId":"programas","summary":"List programs","description":"The business's active programs. You need the `id` of one to sign up a customer. `mecanica` is `sellos` (stamps add up) or `multipase` (a class pack that counts down). `urlAlta` is the program's sign-up link (the one behind the counter QR): send it to a customer and the card installs itself. `niveles` (null if the program has none) holds the ladder with each tier's `clave`, and `origen` says who decides it: `automatico` (visits), `manual` (the business) or `externo` (your system, with `PUT /clientes/{ref}/nivel`).","tags":["Read"],"x-alcance":"lectura","responses":{"200":{"description":"The programs, oldest first.","content":{"application/json":{"example":{"programas":[{"id":"6c1d2e3f-4a5b-4c6d-8e7f-90a1b2c3d4e5","nombre":"Clases","slug":"sellos","mecanica":"sellos","meta":10,"premio":"1 clase gratis","urlAlta":"https://patocard.com/alta/estudio/sellos","niveles":{"origen":"externo","escalera":[{"clave":"member","nombre":"Member"},{"clave":"vip_heat","nombre":"VIP Heat Member"}]}}]}}}},"401":{"description":"`no_autenticado`: No key, malformed, nonexistent or revoked.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"403":{"description":"`plan_no_incluye`: The business's plan doesn't include the REST API.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"429":{"description":"`limite`: too many calls with this key; `Retry-After` says how long to wait.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}}}}},"/clientes":{"get":{"operationId":"buscar-clientes","summary":"Search customers","description":"Searches by identity: phone, email or `refExterna` —the customer's id in your system— (at least one). Phones are compared by their last 10 digits, so `+52 55 1234 5678`, `(55) 1234-5678` and `5512345678` find the same customer. There's no search by name, on purpose. 20 results max.","tags":["Read"],"x-alcance":"lectura","parameters":[{"name":"telefono","in":"query","required":false,"description":"Phone, in any format.","schema":{"type":"string"},"example":"5512345678"},{"name":"email","in":"query","required":false,"description":"Email; case-insensitive.","schema":{"type":"string"},"example":"ana@ejemplo.com"},{"name":"refExterna","in":"query","required":false,"description":"The customer's id in your system (the one you sent in `PUT /clientes/{ref}/nivel`).","schema":{"type":"string"},"example":"OLY-48213"}],"responses":{"200":{"description":"The matching customers, with their cards.","content":{"application/json":{"example":{"clientes":[{"id":"39a8da8f-2a37-4a83-a105-b18d4f8110b5","refExterna":null,"nombre":"Ana López","telefono":"5512345678","email":"ana@ejemplo.com","fechaNacimiento":"1990-04-12","creadoEn":"2026-10-18T16:32:32.000Z","tarjetas":[{"id":"9fb2d02a-2e2f-4567-bd89-e197dc29c0ec","programa":{"id":"6c1d2e3f-4a5b-4c6d-8e7f-90a1b2c3d4e5","nombre":"Clases","mecanica":"sellos"},"activa":true,"saldo":7,"meta":10,"premiosDisponibles":[],"nivel":null,"instalada":true,"url":"https://patocard.com/tarjeta/9fb2d02a-2e2f-4567-bd89-e197dc29c0ec?t=…","creadaEn":"2026-10-18T16:32:32.000Z"}]}]}}}},"400":{"description":"`invalido`: None of `telefono`, `email` or `refExterna` was sent.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"401":{"description":"`no_autenticado`: No key, malformed, nonexistent or revoked.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"403":{"description":"`plan_no_incluye`: The business's plan doesn't include the REST API.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"429":{"description":"`limite`: too many calls with this key; `Retry-After` says how long to wait.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}}}},"post":{"operationId":"alta","summary":"Sign up a customer","description":"Creates the customer and their card in a program. If they already had a card in that program, it's handed back (`200`, `reentrega: true`) instead of duplicated. **By default the customer isn't notified**: with `notificar: true` they get the welcome email (or, if they already had it, their card's link), and `notificacion` says whether it went out. To send them the card through another channel, use `tarjeta.url`.","tags":["Write"],"x-alcance":"escritura","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Up to 100 characters. The same key within 24 h returns the original response without repeating the operation.","schema":{"type":"string","maxLength":100}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["programaId","nombre","telefono"],"properties":{"programaId":{"type":"string","format":"uuid","description":"The program (from `GET /programas`)."},"nombre":{"type":"string","description":"2 to 120 characters."},"telefono":{"type":"string","description":"10 digits, in any format."},"email":{"type":"string","description":"For the welcome email."},"fechaNacimiento":{"type":"string","format":"date","description":"`YYYY-MM-DD`, for the birthday greeting."},"notificar":{"type":"boolean","description":"Notify the customer. Default `false`."}}},"example":{"programaId":"6c1d2e3f-4a5b-4c6d-8e7f-90a1b2c3d4e5","nombre":"Ana López","telefono":"+52 55 1234 5678","email":"ana@ejemplo.com","notificar":true}}}},"responses":{"201":{"description":"Created (`201`) or handed back (`200`).","content":{"application/json":{"example":{"reentrega":false,"cliente":{"id":"39a8da8f-2a37-4a83-a105-b18d4f8110b5","refExterna":null,"nombre":"Ana López","telefono":"5512345678","email":"ana@ejemplo.com","fechaNacimiento":"1990-04-12","creadoEn":"2026-10-18T16:32:32.000Z","tarjetas":[{"id":"9fb2d02a-2e2f-4567-bd89-e197dc29c0ec","programa":{"id":"6c1d2e3f-4a5b-4c6d-8e7f-90a1b2c3d4e5","nombre":"Clases","mecanica":"sellos"},"activa":true,"saldo":0,"meta":10,"premiosDisponibles":[],"nivel":null,"instalada":false,"url":"https://patocard.com/tarjeta/9fb2d02a-2e2f-4567-bd89-e197dc29c0ec?t=…","creadaEn":"2026-10-18T16:32:32.000Z"}]},"tarjeta":{"id":"9fb2d02a-2e2f-4567-bd89-e197dc29c0ec","programa":{"id":"6c1d2e3f-4a5b-4c6d-8e7f-90a1b2c3d4e5","nombre":"Clases","mecanica":"sellos"},"activa":true,"saldo":0,"meta":10,"premiosDisponibles":[],"nivel":null,"instalada":false,"url":"https://patocard.com/tarjeta/9fb2d02a-2e2f-4567-bd89-e197dc29c0ec?t=…","creadaEn":"2026-10-18T16:32:32.000Z","cliente":{"id":"39a8da8f-2a37-4a83-a105-b18d4f8110b5","nombre":"Ana López"}},"notificacion":{"tipo":"bienvenida","enviada":true}}}}},"400":{"description":"`invalido`: A field fails validation (`detalle.campo` says which).","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"401":{"description":"`no_autenticado`: No key, malformed, nonexistent or revoked.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"402":{"description":"`cuenta_pausada`: The business's account is paused (the trial ended or a charge failed). Nothing is deleted.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"403":{"description":"`plan_no_incluye`: The business's plan doesn't include the REST API. `alcance_insuficiente`: The key is read-only.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"404":{"description":"`no_encontrado`: The program doesn't belong to this business.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"409":{"description":"`conflicto`: The program is inactive.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"429":{"description":"`limite`: too many calls with this key; `Retry-After` says how long to wait.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}}}}},"/clientes/{id}":{"get":{"operationId":"ver-cliente","summary":"Get a customer","description":"The customer with all their cards at the business.","tags":["Read"],"x-alcance":"lectura","parameters":[{"name":"id","in":"path","required":true,"description":"The customer's id.","schema":{"type":"string","format":"uuid"},"example":"39a8da8f-2a37-4a83-a105-b18d4f8110b5"}],"responses":{"200":{"description":"The customer.","content":{"application/json":{"example":{"cliente":{"id":"39a8da8f-2a37-4a83-a105-b18d4f8110b5","refExterna":null,"nombre":"Ana López","telefono":"5512345678","email":"ana@ejemplo.com","fechaNacimiento":"1990-04-12","creadoEn":"2026-10-18T16:32:32.000Z","tarjetas":[{"id":"9fb2d02a-2e2f-4567-bd89-e197dc29c0ec","programa":{"id":"6c1d2e3f-4a5b-4c6d-8e7f-90a1b2c3d4e5","nombre":"Clases","mecanica":"sellos"},"activa":true,"saldo":7,"meta":10,"premiosDisponibles":[],"nivel":null,"instalada":true,"url":"https://patocard.com/tarjeta/9fb2d02a-2e2f-4567-bd89-e197dc29c0ec?t=…","creadaEn":"2026-10-18T16:32:32.000Z"}]}}}}},"401":{"description":"`no_autenticado`: No key, malformed, nonexistent or revoked.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"403":{"description":"`plan_no_incluye`: The business's plan doesn't include the REST API.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"404":{"description":"`no_encontrado`: It doesn't exist at this business.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"429":{"description":"`limite`: too many calls with this key; `Retry-After` says how long to wait.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}}}}},"/tarjetas/{id}":{"get":{"operationId":"ver-tarjeta","summary":"Get a card","description":"Balance, goal, available rewards, tier, whether the customer already added it to their wallet, and `url`: the link the customer opens or installs it with. `saldo` is stamps in a stamp program and classes left in a pack.","tags":["Read"],"x-alcance":"lectura","parameters":[{"name":"id","in":"path","required":true,"description":"The card's id (it's also what its QR contains).","schema":{"type":"string","format":"uuid"},"example":"9fb2d02a-2e2f-4567-bd89-e197dc29c0ec"}],"responses":{"200":{"description":"The card.","content":{"application/json":{"example":{"tarjeta":{"id":"9fb2d02a-2e2f-4567-bd89-e197dc29c0ec","programa":{"id":"6c1d2e3f-4a5b-4c6d-8e7f-90a1b2c3d4e5","nombre":"Clases","mecanica":"sellos"},"activa":true,"saldo":7,"meta":10,"premiosDisponibles":[],"nivel":null,"instalada":true,"url":"https://patocard.com/tarjeta/9fb2d02a-2e2f-4567-bd89-e197dc29c0ec?t=…","creadaEn":"2026-10-18T16:32:32.000Z","cliente":{"id":"39a8da8f-2a37-4a83-a105-b18d4f8110b5","nombre":"Ana López"}}}}}},"401":{"description":"`no_autenticado`: No key, malformed, nonexistent or revoked.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"403":{"description":"`plan_no_incluye`: The business's plan doesn't include the REST API.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"404":{"description":"`no_encontrado`: It doesn't exist at this business.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"429":{"description":"`limite`: too many calls with this key; `Retry-After` says how long to wait.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}}}}},"/tarjetas/{id}/visitas":{"post":{"operationId":"visita","summary":"Record a visit","description":"The customer came in. In a stamp program it adds one —with the program's promotions, referrals and daily cap, just like the counter scanner—; in a pack it takes off one class. The daily cap can't be skipped through the API. If this visit completes the goal, `premiosGanados` says so.","tags":["Write"],"x-alcance":"escritura","parameters":[{"name":"id","in":"path","required":true,"description":"The card's id.","schema":{"type":"string","format":"uuid"},"example":"9fb2d02a-2e2f-4567-bd89-e197dc29c0ec"},{"name":"Idempotency-Key","in":"header","required":false,"description":"Up to 100 characters. The same key within 24 h returns the original response without repeating the operation.","schema":{"type":"string","maxLength":100}}],"responses":{"201":{"description":"The card, already updated.","content":{"application/json":{"example":{"tarjeta":{"id":"9fb2d02a-2e2f-4567-bd89-e197dc29c0ec","programa":{"id":"6c1d2e3f-4a5b-4c6d-8e7f-90a1b2c3d4e5","nombre":"Clases","mecanica":"sellos"},"activa":true,"saldo":0,"meta":10,"premiosDisponibles":[{"id":"a80709d3-3773-4ae5-8dc0-a193dc47e14a","descripcion":"1 clase gratis","venceEn":null}],"nivel":null,"instalada":true,"url":"https://patocard.com/tarjeta/9fb2d02a-2e2f-4567-bd89-e197dc29c0ec?t=…","creadaEn":"2026-10-18T16:32:32.000Z","cliente":{"id":"39a8da8f-2a37-4a83-a105-b18d4f8110b5","nombre":"Ana López"}},"premiosGanados":["1 clase gratis"],"promocion":null,"subioNivel":null}}}},"401":{"description":"`no_autenticado`: No key, malformed, nonexistent or revoked.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"402":{"description":"`cuenta_pausada`: The business's account is paused (the trial ended or a charge failed). Nothing is deleted.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"403":{"description":"`plan_no_incluye`: The business's plan doesn't include the REST API. `alcance_insuficiente`: The key is read-only.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"404":{"description":"`no_encontrado`: The card doesn't belong to this business.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"409":{"description":"`conflicto`: `detalle.motivo`: `limite_diario` (hit today's cap), `sin_saldo` (pack used up), `tarjeta_inactiva`…","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"429":{"description":"`limite`: too many calls with this key; `Retry-After` says how long to wait.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}}}}},"/premios/{id}/canje":{"post":{"operationId":"canje","summary":"Redeem a reward","description":"Marks an available reward as redeemed. The `id` comes from `tarjeta.premiosDisponibles`.","tags":["Write"],"x-alcance":"escritura","parameters":[{"name":"id","in":"path","required":true,"description":"The reward's id.","schema":{"type":"string","format":"uuid"},"example":"a80709d3-3773-4ae5-8dc0-a193dc47e14a"},{"name":"Idempotency-Key","in":"header","required":false,"description":"Up to 100 characters. The same key within 24 h returns the original response without repeating the operation.","schema":{"type":"string","maxLength":100}}],"responses":{"200":{"description":"The redeemed reward and the card.","content":{"application/json":{"example":{"premio":{"id":"a80709d3-3773-4ae5-8dc0-a193dc47e14a","descripcion":"1 clase gratis","canjeadoEn":"2026-10-18T17:01:00.000Z"},"tarjeta":{"id":"9fb2d02a-2e2f-4567-bd89-e197dc29c0ec","programa":{"id":"6c1d2e3f-4a5b-4c6d-8e7f-90a1b2c3d4e5","nombre":"Clases","mecanica":"sellos"},"activa":true,"saldo":0,"meta":10,"premiosDisponibles":[],"nivel":null,"instalada":true,"url":"https://patocard.com/tarjeta/9fb2d02a-2e2f-4567-bd89-e197dc29c0ec?t=…","creadaEn":"2026-10-18T16:32:32.000Z","cliente":{"id":"39a8da8f-2a37-4a83-a105-b18d4f8110b5","nombre":"Ana López"}}}}}},"401":{"description":"`no_autenticado`: No key, malformed, nonexistent or revoked.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"402":{"description":"`cuenta_pausada`: The business's account is paused (the trial ended or a charge failed). Nothing is deleted.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"403":{"description":"`plan_no_incluye`: The business's plan doesn't include the REST API. `alcance_insuficiente`: The key is read-only.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"404":{"description":"`no_encontrado`: The reward doesn't belong to this business.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"409":{"description":"`conflicto`: `detalle.motivo`: `premio_ya_canjeado` or `premio_vencido`.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"429":{"description":"`limite`: too many calls with this key; `Retry-After` says how long to wait.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}}}}},"/tarjetas/{id}/mensajes":{"post":{"operationId":"mensaje","summary":"Send the customer a message","description":"A notification to the customer's phone: it rings on the lock screen and stays written on the card, in Apple and Google Wallet. It's for what your system knows and PatoCard doesn't: “your class is tomorrow at 7”, “you have 2 classes left”. It accepts the panel's placeholders: `{cliente}`, `{sellos}`, `{meta}`, `{faltan}`, `{premio}`, `{nivel}`. Apple shows the `cuerpo`; Google shows `titulo` and `cuerpo`. **Cap: 3 messages per card every 24 hours**, counting the business's automatic ones (it's Google's limit, and we apply it on Apple too so we don't pester). The card must be installed (`instalada: true`). Requires a plan that includes card messages. It shows up in the panel's history as sent by the API.","tags":["Write"],"x-alcance":"escritura","parameters":[{"name":"id","in":"path","required":true,"description":"The card's id.","schema":{"type":"string","format":"uuid"},"example":"9fb2d02a-2e2f-4567-bd89-e197dc29c0ec"},{"name":"Idempotency-Key","in":"header","required":false,"description":"Up to 100 characters. The same key within 24 h returns the original response without repeating the operation.","schema":{"type":"string","maxLength":100}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["titulo","cuerpo"],"properties":{"titulo":{"type":"string","description":"2 to 40 characters. Google shows it."},"cuerpo":{"type":"string","description":"4 to 180 characters, with optional placeholders."}}},"example":{"titulo":"Ila Hot Room","cuerpo":"{cliente}, tu clase de Hot Pilates es mañana a las 7:00. ¡Te esperamos!"}}}},"responses":{"201":{"description":"Delivered. `entrega` says which wallet it went through.","content":{"application/json":{"example":{"mensaje":{"id":"5b1e0c2a-8d4f-4e7a-9c3b-2f6a1d8e4c70","titulo":"Ila Hot Room","cuerpo":"Ana López, tu clase de Hot Pilates es mañana a las 7:00. ¡Te esperamos!"},"entrega":{"apple":true,"google":false},"avisosRestantesHoy":2,"tarjetaId":"9fb2d02a-2e2f-4567-bd89-e197dc29c0ec"}}}},"400":{"description":"`invalido`: `titulo` or `cuerpo` out of range (`detalle.campo`).","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"401":{"description":"`no_autenticado`: No key, malformed, nonexistent or revoked.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"402":{"description":"`cuenta_pausada`: The business's account is paused (the trial ended or a charge failed). Nothing is deleted.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"403":{"description":"`plan_no_incluye`: The business's plan doesn't include card messages. `plan_no_incluye`: The business's plan doesn't include the REST API. `alcance_insuficiente`: The key is read-only.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"404":{"description":"`no_encontrado`: The card doesn't belong to this business.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"409":{"description":"`conflicto`: `detalle.motivo`: `sin_pase` (it's not in their wallet: send them `tarjeta.url`), `cuota_del_pase` (already got 3 messages in 24 h), `no_entregado` (no phone has it anymore), `tarjeta_inactiva`.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"429":{"description":"`limite`: too many calls with this key; `Retry-After` says how long to wait.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}}}}},"/clientes/{id}/nivel":{"put":{"operationId":"nivel","summary":"Set the tier from your system","description":"For when your software (bookings, gym) sells and cancels the membership: you say which tier each customer has and their card changes design on its own in Apple and Google Wallet. The program must have its tier in the hands of **«Tu sistema»** (Your system; Ajustes → Programas → Niveles in the panel); the keys come from `GET /programas`. **Creates and updates**: if PatoCard doesn't know the customer and you send `cliente`, it signs them up (`201`) and from then on recognizes them by your `{id}`; if they already existed with that phone, it links them to your `{id}`. It's a true PUT: sending the same thing twice doesn't cause a second change, push or webhook. With `vence`, once that day passes (in the business's time zone) the card loses the tier on its own; renewing is sending it again with another date. When moving up, the customer gets the tier greeting if the business has it on, and your webhooks get `nivel.cambio`.","tags":["Write"],"x-alcance":"escritura","parameters":[{"name":"id","in":"path","required":true,"description":"The customer's id in YOUR system (up to 100 characters). It also accepts the PatoCard `id`.","schema":{"type":"string"},"example":"OLY-48213"},{"name":"Idempotency-Key","in":"header","required":false,"description":"Up to 100 characters. The same key within 24 h returns the original response without repeating the operation.","schema":{"type":"string","maxLength":100}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["nivel"],"properties":{"nivel":{"type":"string","description":"The tier's `clave`, or `null` to remove it (the membership was cancelled)."},"vence":{"type":"string","format":"date","description":"`YYYY-MM-DD`, the last valid day. Without it, the tier doesn't expire."},"programaId":{"type":"string","format":"uuid","description":"Only if the business has more than one program with its tier set by «Tu sistema»."},"cliente":{"type":"object","description":"`{ nombre, telefono, email? }` to sign them up if PatoCard doesn't know them. Without it, an unknown customer is a `404`."}}},"example":{"nivel":"vip_heat","vence":"2026-11-30","cliente":{"nombre":"Ana López","telefono":"+52 55 1234 5678"}}}}},"responses":{"200":{"description":"Updated (`200`) or customer signed up (`201`). `cambio` is null if they already had that tier.","content":{"application/json":{"example":{"clienteCreado":false,"cambio":{"de":"member","a":"vip_heat","subio":true},"cliente":{"id":"39a8da8f-2a37-4a83-a105-b18d4f8110b5","refExterna":"OLY-48213","nombre":"Ana López","telefono":"5512345678","email":"ana@ejemplo.com","fechaNacimiento":"1990-04-12","creadoEn":"2026-10-18T16:32:32.000Z","tarjetas":[{"id":"9fb2d02a-2e2f-4567-bd89-e197dc29c0ec","programa":{"id":"6c1d2e3f-4a5b-4c6d-8e7f-90a1b2c3d4e5","nombre":"Clases","mecanica":"sellos"},"activa":true,"saldo":7,"meta":10,"premiosDisponibles":[],"nivel":{"clave":"vip_heat","nombre":"VIP Heat Member","vence":"2026-12-01T06:00:00.000Z"},"instalada":true,"url":"https://patocard.com/tarjeta/9fb2d02a-2e2f-4567-bd89-e197dc29c0ec?t=…","creadaEn":"2026-10-18T16:32:32.000Z"}]},"tarjeta":{"id":"9fb2d02a-2e2f-4567-bd89-e197dc29c0ec","programa":{"id":"6c1d2e3f-4a5b-4c6d-8e7f-90a1b2c3d4e5","nombre":"Clases","mecanica":"sellos"},"activa":true,"saldo":7,"meta":10,"premiosDisponibles":[],"nivel":{"clave":"vip_heat","nombre":"VIP Heat Member","vence":"2026-12-01T06:00:00.000Z"},"instalada":true,"url":"https://patocard.com/tarjeta/9fb2d02a-2e2f-4567-bd89-e197dc29c0ec?t=…","creadaEn":"2026-10-18T16:32:32.000Z","cliente":{"id":"39a8da8f-2a37-4a83-a105-b18d4f8110b5","nombre":"Ana López"}}}}}},"400":{"description":"`invalido`: A field fails validation (`detalle.campo`). A `nivel` that doesn't exist brings `detalle.validos` with the right keys; several programs with an external tier and no `programaId` brings `detalle.programas`.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"401":{"description":"`no_autenticado`: No key, malformed, nonexistent or revoked.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"402":{"description":"`cuenta_pausada`: The business's account is paused (the trial ended or a charge failed). Nothing is deleted.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"403":{"description":"`plan_no_incluye`: The business's plan doesn't include the REST API. `alcance_insuficiente`: The key is read-only.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"404":{"description":"`no_encontrado`: The customer doesn't exist and you didn't send `cliente`; or the program doesn't belong to this business.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"409":{"description":"`conflicto`: `detalle.motivo`: `origen_no_externo` (that program's tier isn't decided by your system), `telefono_de_otra_ref` (that phone is already linked to another `{id}` of yours), `tarjeta_inactiva`, `en_proceso`.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}},"429":{"description":"`limite`: too many calls with this key; `Retry-After` says how long to wait.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["codigo","mensaje"],"properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"},"detalle":{}}}}}}}}}}}},"webhooks":{"cliente.alta":{"post":{"summary":"New customer","description":"Someone got their card: through the counter QR, a link, the API or an import. Signed with the PatoCard-Firma header; answer 2xx or it's retried.","requestBody":{"content":{"application/json":{"example":{"id":"518d8b02-89d1-4245-aeff-70386669a2cc","tipo":"cliente.alta","creadoEn":"2026-10-18T17:01:00.000Z","negocio":{"slug":"ila"},"datos":{"tarjeta":{"id":"9fb2d02a-2e2f-4567-bd89-e197dc29c0ec","programa":{"id":"6c1d2e3f-4a5b-4c6d-8e7f-90a1b2c3d4e5","nombre":"Clases","mecanica":"sellos"},"activa":true,"saldo":8,"meta":10,"premiosDisponibles":[],"nivel":null,"instalada":true,"url":"https://patocard.com/tarjeta/9fb2d02a-2e2f-4567-bd89-e197dc29c0ec?t=…","creadaEn":"2026-10-18T16:32:32.000Z","cliente":{"id":"39a8da8f-2a37-4a83-a105-b18d4f8110b5","nombre":"Ana López"}},"cantidad":1,"origen":"escaner"}}}}},"responses":{"200":{"description":"Received. Any 2xx works."}}}},"sello.registrado":{"post":{"summary":"Stamp","description":"A visit added stamps in a stamp program. Signed with the PatoCard-Firma header; answer 2xx or it's retried.","requestBody":{"content":{"application/json":{"example":{"id":"518d8b02-89d1-4245-aeff-70386669a2cc","tipo":"sello.registrado","creadoEn":"2026-10-18T17:01:00.000Z","negocio":{"slug":"ila"},"datos":{"tarjeta":{"id":"9fb2d02a-2e2f-4567-bd89-e197dc29c0ec","programa":{"id":"6c1d2e3f-4a5b-4c6d-8e7f-90a1b2c3d4e5","nombre":"Clases","mecanica":"sellos"},"activa":true,"saldo":8,"meta":10,"premiosDisponibles":[],"nivel":null,"instalada":true,"url":"https://patocard.com/tarjeta/9fb2d02a-2e2f-4567-bd89-e197dc29c0ec?t=…","creadaEn":"2026-10-18T16:32:32.000Z","cliente":{"id":"39a8da8f-2a37-4a83-a105-b18d4f8110b5","nombre":"Ana López"}},"cantidad":1,"origen":"escaner"}}}}},"responses":{"200":{"description":"Received. Any 2xx works."}}}},"visita.registrada":{"post":{"summary":"Class used","description":"A visit took one class off a pack. Signed with the PatoCard-Firma header; answer 2xx or it's retried.","requestBody":{"content":{"application/json":{"example":{"id":"518d8b02-89d1-4245-aeff-70386669a2cc","tipo":"visita.registrada","creadoEn":"2026-10-18T17:01:00.000Z","negocio":{"slug":"ila"},"datos":{"tarjeta":{"id":"9fb2d02a-2e2f-4567-bd89-e197dc29c0ec","programa":{"id":"6c1d2e3f-4a5b-4c6d-8e7f-90a1b2c3d4e5","nombre":"Clases","mecanica":"sellos"},"activa":true,"saldo":8,"meta":10,"premiosDisponibles":[],"nivel":null,"instalada":true,"url":"https://patocard.com/tarjeta/9fb2d02a-2e2f-4567-bd89-e197dc29c0ec?t=…","creadaEn":"2026-10-18T16:32:32.000Z","cliente":{"id":"39a8da8f-2a37-4a83-a105-b18d4f8110b5","nombre":"Ana López"}},"cantidad":1,"origen":"escaner"}}}}},"responses":{"200":{"description":"Received. Any 2xx works."}}}},"paquete.cargado":{"post":{"summary":"Pack loaded","description":"Classes were loaded onto a pack (the customer bought). Signed with the PatoCard-Firma header; answer 2xx or it's retried.","requestBody":{"content":{"application/json":{"example":{"id":"518d8b02-89d1-4245-aeff-70386669a2cc","tipo":"paquete.cargado","creadoEn":"2026-10-18T17:01:00.000Z","negocio":{"slug":"ila"},"datos":{"tarjeta":{"id":"9fb2d02a-2e2f-4567-bd89-e197dc29c0ec","programa":{"id":"6c1d2e3f-4a5b-4c6d-8e7f-90a1b2c3d4e5","nombre":"Clases","mecanica":"sellos"},"activa":true,"saldo":8,"meta":10,"premiosDisponibles":[],"nivel":null,"instalada":true,"url":"https://patocard.com/tarjeta/9fb2d02a-2e2f-4567-bd89-e197dc29c0ec?t=…","creadaEn":"2026-10-18T16:32:32.000Z","cliente":{"id":"39a8da8f-2a37-4a83-a105-b18d4f8110b5","nombre":"Ana López"}},"cantidad":1,"origen":"escaner"}}}}},"responses":{"200":{"description":"Received. Any 2xx works."}}}},"premio.ganado":{"post":{"summary":"Reward earned","description":"The customer completed the goal and has a reward to redeem. Signed with the PatoCard-Firma header; answer 2xx or it's retried.","requestBody":{"content":{"application/json":{"example":{"id":"518d8b02-89d1-4245-aeff-70386669a2cc","tipo":"premio.ganado","creadoEn":"2026-10-18T17:01:00.000Z","negocio":{"slug":"ila"},"datos":{"tarjeta":{"id":"9fb2d02a-2e2f-4567-bd89-e197dc29c0ec","programa":{"id":"6c1d2e3f-4a5b-4c6d-8e7f-90a1b2c3d4e5","nombre":"Clases","mecanica":"sellos"},"activa":true,"saldo":8,"meta":10,"premiosDisponibles":[],"nivel":null,"instalada":true,"url":"https://patocard.com/tarjeta/9fb2d02a-2e2f-4567-bd89-e197dc29c0ec?t=…","creadaEn":"2026-10-18T16:32:32.000Z","cliente":{"id":"39a8da8f-2a37-4a83-a105-b18d4f8110b5","nombre":"Ana López"}},"cantidad":1,"origen":"escaner"}}}}},"responses":{"200":{"description":"Received. Any 2xx works."}}}},"premio.canjeado":{"post":{"summary":"Reward redeemed","description":"A reward was redeemed. Signed with the PatoCard-Firma header; answer 2xx or it's retried.","requestBody":{"content":{"application/json":{"example":{"id":"518d8b02-89d1-4245-aeff-70386669a2cc","tipo":"premio.canjeado","creadoEn":"2026-10-18T17:01:00.000Z","negocio":{"slug":"ila"},"datos":{"tarjeta":{"id":"9fb2d02a-2e2f-4567-bd89-e197dc29c0ec","programa":{"id":"6c1d2e3f-4a5b-4c6d-8e7f-90a1b2c3d4e5","nombre":"Clases","mecanica":"sellos"},"activa":true,"saldo":8,"meta":10,"premiosDisponibles":[],"nivel":null,"instalada":true,"url":"https://patocard.com/tarjeta/9fb2d02a-2e2f-4567-bd89-e197dc29c0ec?t=…","creadaEn":"2026-10-18T16:32:32.000Z","cliente":{"id":"39a8da8f-2a37-4a83-a105-b18d4f8110b5","nombre":"Ana López"}},"cantidad":1,"origen":"escaner"}}}}},"responses":{"200":{"description":"Received. Any 2xx works."}}}},"nivel.cambio":{"post":{"summary":"Tier change","description":"The customer moved up or down a tier. Signed with the PatoCard-Firma header; answer 2xx or it's retried.","requestBody":{"content":{"application/json":{"example":{"id":"518d8b02-89d1-4245-aeff-70386669a2cc","tipo":"nivel.cambio","creadoEn":"2026-10-18T17:01:00.000Z","negocio":{"slug":"ila"},"datos":{"tarjeta":{"id":"9fb2d02a-2e2f-4567-bd89-e197dc29c0ec","programa":{"id":"6c1d2e3f-4a5b-4c6d-8e7f-90a1b2c3d4e5","nombre":"Clases","mecanica":"sellos"},"activa":true,"saldo":8,"meta":10,"premiosDisponibles":[],"nivel":null,"instalada":true,"url":"https://patocard.com/tarjeta/9fb2d02a-2e2f-4567-bd89-e197dc29c0ec?t=…","creadaEn":"2026-10-18T16:32:32.000Z","cliente":{"id":"39a8da8f-2a37-4a83-a105-b18d4f8110b5","nombre":"Ana López"}},"cantidad":1,"origen":"escaner"}}}}},"responses":{"200":{"description":"Received. Any 2xx works."}}}}}}