Cómo se construye la firma de un webhook, y cómo verificarla.
Listo manda los webhooks a una URL que tú le diste, sin ninguna credencial en la
petición. La firma es la credencial. Es lo que te dice que un evento vino de
Listo, llegó sin alteraciones, y no es uno que alguien capturó antes y volvió a
mandar.Cada evento lleva un encabezado:
X-Listo-Signature: t=1753728063,v1=8f2c9d4e...
t es la hora Unix, en segundos, en la que se firmó el evento.
v1 es un HMAC-SHA256 en hexadecimal, con tu secreto de firma como llave,
sobre la cadena "<t>.<raw body>": el valor de t, un punto, y el cuerpo de
la petición tal como llegó.
Fíjate en que t va dentro de la cadena que se firma, no nada más al lado.
Ahí está toda la diferencia contra un HMAC simple del cuerpo: uno simple sigue
siendo válido para siempre, así que cualquiera que haya visto una sola petición
válida podría reenviarla cuando se le antojara. Meter la marca de tiempo dentro
del resumen obliga a que una repetición o conserve el t original, y caiga
fuera de la ventana de abajo, o lo cambie, e invalide la firma.
# Verifies the signature on an incoming Listo webhook before trusting a byte of# it. Reads the raw request body on stdin, the way your web framework hands it# to you, and refuses anything that does not check out.## LISTO_SIGNATURE='t=...,v1=...' LISTO_WEBHOOK_SECRETS=whsec_a,whsec_b \# ruby verify_webhook_signature.rb < body.json#require "json"require "openssl"# The window a signature stays good for, matching the one Listo signs against.# It is what stops a request someone captured from being replayed at you later.TOLERANCE_SECONDS = 300# `secrets` is a LIST because a rotation has two secrets live at once: accept# either while you swap over, then drop the old one.def listo_signature_valid?(payload, header, secrets, now: Time.now) match = /\At=(\d+),v1=(\h+)\z/.match(header.to_s) return false if match.nil? timestamp = match[1].to_i signature = match[2] # Checked in BOTH directions. A timestamp far in the past is the replay this # scheme exists to stop; one far in the future is the same attack against a # clock nobody looked at. return false if (now.to_i - timestamp).abs > TOLERANCE_SECONDS secrets.any? do |secret| expected = OpenSSL::HMAC.hexdigest("SHA256", secret, "#{timestamp}.#{payload}") OpenSSL.secure_compare(expected, signature) endend# The RAW bytes, before any JSON parsing. Parsing and re-serializing changes# them (key order, escapes, whitespace) and the signature covers what was sent,# not what your JSON library would have sent.payload = $stdin.readheader = ENV.fetch("LISTO_SIGNATURE", nil)secrets = ENV.fetch("LISTO_WEBHOOK_SECRETS").split(",")unless listo_signature_valid?(payload, header, secrets) # Answer 400 and stop. Do not parse it, do not act on it, do not log it as an # event you received. abort("signature rejected")endevent = JSON.parse(payload)# Events arrive at least once and in no guaranteed order, so treat `id` as the# thing you deduplicate on and the object's own timestamps as the thing you# order by. Answer 2xx quickly and do the work afterwards.puts "#{event["type"]} #{event["id"]}"case event["type"]when "delivery.status_changed", "delivery.updated" delivery = event["data"] puts "order #{delivery["external_id"]} is #{delivery["status"]}"when "delivery.courier_location" location = event.dig("data", "location") puts "courier at #{location["lat"]},#{location["lng"]}"else # A new type is an additive change, so ignore what you do not recognise # rather than failing on it. puts "ignored"end
Cuatro reglas, y cada una es una forma de que la verificación esté mal mientras
aparenta estar bien.Firma los bytes tal como llegaron. Sobre lo que llegó por el cable, antes de
cualquier parseo de JSON. Parsear y volver a serializar cambia los bytes, porque
tu librería de JSON tiene sus propias ideas sobre el orden de las llaves, las
secuencias de escape y los espacios, y la firma cubre lo que se mandó, no lo que
tu librería habría mandado. Casi cualquier framework web te da el cuerpo sin
procesar si se lo pides; averigua cómo lo hace el tuyo antes de escribir la
verificación.Revisa la marca de tiempo en las dos direcciones. Rechaza cualquier cosa con
más de cinco minutos de antigüedad, que es la repetición que este esquema existe
para frenar, y cualquier cosa con más de cinco minutos hacia el futuro.
Saltarte la segunda mitad le regala a un atacante una ventana arbitrariamente
larga con solo escoger un t grande.Compara en tiempo constante. Usa la comparación de tiempo constante de tu
lenguaje, no ==. Una comparación que se corta en el primer byte distinto
filtra qué tanto acertó el intento, y con eso basta para ir sacando una firma
válida byte por byte.Falla cerrado. Un encabezado mal formado, un encabezado ausente, una marca
de tiempo que no se puede leer y una firma que no coincide son todos la misma
respuesta: no es auténtico. Rechaza con un 400, y no parsees ni actúes sobre
el cuerpo. Nunca dejes que el verificador lance una excepción; una excepción en
un verificador es un 500 donde iba un rechazo.
Puedes tener dos secretos vivos al mismo tiempo, y eso es lo que hace posible
una rotación sin perder eventos. Listo firma con el principal; tú aceptas
cualquiera de los dos.
Agrega un segundo secreto en el
panel de socios. Todavía no cambia nada:
Listo sigue firmando con el primero.
Enséñale los dos a tu verificador. Por eso la verificación de arriba
recibe una lista: acepta un evento que valide con cualquiera de los dos.
Promueve el nuevo secreto. Listo empieza a firmar con él. Tu endpoint
sigue funcionando durante el cambio, porque ya acepta los dos.
Quita el viejo, en el panel y en tu propia configuración.
Hazlo en ese orden. Si promueves antes del paso 2, cada evento en vuelo lo
rechaza un endpoint que nunca ha visto el secreto nuevo.
Un secreto es un secretoGuarda los secretos de firma como guardas las contraseñas: del lado del
servidor, fuera de tu repositorio, fuera de cualquier cosa que alcance un
navegador. Quien tenga uno puede falsificar un evento que tu verificador va a
aceptar, que es lo mismo que poder decirle a tu sistema que un pedido se
entregó.
El mundo real y el de prueba tienen cada uno su URL de endpoint y su secreto de
firma. Un secreto de un modo nunca valida un evento del otro, y eso es lo que
impide que un despliegue de staging pueda aceptar tráfico de producción. Rótalos
por separado.Poner todo esto a trabajar, incluyendo cómo responder, cómo deduplicar y cómo
funcionan los reintentos, es
recibe y verifica webhooks.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Listo Partner API","description":"Quote, create and track deliveries, and manage your balance, through the Listo Partner Delivery API.","colors":{"primary":"#15171C","light":"#F4F4F5","dark":"#15171C"},"logo":{"light":"https://mintcdn.com/listo-c5a11a00/mreCwXzcEA2bSZog/logo/light.svg?fit=max\u0026auto=format\u0026n=mreCwXzcEA2bSZog\u0026q=85\u0026s=da2b28d464dc6987329dfd5971085dd7","dark":"https://mintcdn.com/listo-c5a11a00/mreCwXzcEA2bSZog/logo/dark.svg?fit=max\u0026auto=format\u0026n=mreCwXzcEA2bSZog\u0026q=85\u0026s=ad013a6a0d979eb46c1cea550ec6a460","href":"/"},"favicon":"https://mintcdn.com/listo-c5a11a00/mreCwXzcEA2bSZog/favicon.svg?fit=max\u0026auto=format\u0026n=mreCwXzcEA2bSZog\u0026q=85\u0026s=f790496dfe0c2ad9971d8de95e45be8d","api":{"playground":{"display":"interactive"}},"thumbnails":{"preset":"minimal","appearance":"dark","background":"https://mintcdn.com/listo-c5a11a00/lF-Gm03tnDMquh_z/images/og-background.jpg?fit=max\u0026auto=format\u0026n=lF-Gm03tnDMquh_z\u0026q=85\u0026s=d73469201c8ffe28afc598d23fde5d84","fonts":{"family":"Archivo ExtraBold","source":"fonts/archivo-800.ttf","format":"ttf"},"eyebrow":{"source":"none"}},"markdown":{"instructions":["Notes on the Listo Partner Delivery API:","- Every endpoint is under `https://api.listo.delivery/v1/` and authenticates with a bearer API key.","- This documentation site is at https://docs.listo.delivery. The full machine-readable reference is the OpenAPI document at https://api.listo.delivery/docs/openapi.yaml (served by the API host, not by this site).","- Any page of this site is also available as raw markdown by appending `.md` to its URL, for example https://docs.listo.delivery/en/guides/webhooks.md. The index of every page is https://docs.listo.delivery/llms.txt and all of them in one file is https://docs.listo.delivery/llms-full.txt.","- Every page is published in English under https://docs.listo.delivery/en/ and in Spanish under https://docs.listo.delivery/es/, with the same path after the language. The API reference is under https://docs.listo.delivery/api-reference/ in English and https://docs.listo.delivery/es/api-reference/ in Spanish.","- To debug an integration yourself: `GET /v1/request_logs` lists the calls your keys made with what you sent and what was answered, `GET /v1/events` lists the events Listo emitted, `GET /v1/webhook_deliveries` lists every attempt to deliver them, `POST /v1/events/{id}/resend` sends one event again and `POST /v1/test_webhooks` sends a sample event (`\"test\": true`). The page https://docs.listo.delivery/en/guides/debugging describes them. A resent event is a snapshot from when it happened; `GET /v1/deliveries` is still how you recover current state.","- Every error response has `error.doc_url`, a page that explains that error code and what to do, and `error.request_id`, the same value as the `X-Request-Id` response header. All the pages are listed at https://docs.listo.delivery/en/errors. Filter `GET /v1/request_logs` with `request_id` to read the logged call.","- A `409 account_exists` from `POST /v1/stores` means the restaurant already has its own Listo account: connect it instead of creating it, as the page https://docs.listo.delivery/en/guides/connect-existing-account describes.","- Every live store carries one Plan Listo, charged to the partner. The exception is a connected restaurant that had already paid its current month: it keeps paying its own plan until its next renewal, shown as `paid_by: \"store\"` with the handover date in `pending_paid_by_on`. A `402 plan_required` from a quote, a delivery create or a retry means the store's plan is not paid or has ended; the page https://docs.listo.delivery/en/guides/plan-and-billing describes the plan, the `plan` block on a store and how to end or restart it.","- An AI assistant (Claude Code, Cursor, Codex) can act through the same API key at `https://api.listo.delivery/mcp`, an MCP server over Streamable HTTP authenticated with `Authorization: Bearer \u003cAPI key>`. Every tool runs the matching `/v1/` endpoint, and each one that moves money first previews and then needs a confirmation token; the page https://docs.listo.delivery/en/guides/connect-ai-client lists the tools and describes the two steps."]},"styling":{"latex":true},"navigation":{"languages":[{"language":"en","default":true,"navbar":{"links":[{"href":"https://status.listo.delivery","label":"Status"}]},"href":"en/quickstart"},{"language":"es","navbar":{"links":[{"href":"https://status.listo.delivery","label":"Estado del servicio"}]},"href":"es/quickstart"}]}},"deployment":{"deploymentMetadataValue":{"subdomain":"listo-c5a11a00","hasAudioNarration":false,"actualSubdomain":"listo-c5a11a00","customDomains":["docs.listo.delivery"],"gitSource":{"type":"github","owner":"davidalejandroaguilar","repo":"listo","deployBranch":"main","contentDirectory":"docs-site","isPrivate":true,"mountPath":"","label":"","_id":"6aed6954347cccfbc77ed1c5"},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6aeeb167ae7fce64eae954de","clientVersion":"0.0.4076","searchFilterCounts":[{"language":"en","tag":"Errors","count":43},{"language":"en","tag":"Reference","count":43},{"language":"es","tag":"Errores","count":43},{"language":"es","tag":"Referencia","count":43},{"language":"en","tag":"Guides","count":9},{"language":"es","tag":"Guías","count":9},{"language":"en","tag":"Stores","count":8},{"language":"es","tag":"Tiendas","count":8},{"language":"en","tag":"Deliveries","count":7},{"language":"es","tag":"Envíos","count":7},{"language":"en","tag":"Webhooks","count":6},{"language":"es","tag":"Webhooks","count":6},{"language":"en","tag":"Concepts","count":5},{"language":"es","tag":"Conceptos","count":5},{"language":"en","tag":"Card onboarding","count":4},{"language":"en","tag":"Events","count":4},{"language":"es","tag":"Alta de cobros con tarjeta","count":4},{"language":"es","tag":"Eventos","count":4},{"language":"en","tag":"Withdrawals","count":3},{"language":"es","tag":"Retiros","count":3}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"comment-mode","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":":is(#sidebar-content,#mobile-nav) li[data-active=\"true\"]>a{background-color:#ffc400;color:#15171c}"}],"page":{"pagePath":"es/concepts/signing","slug":"/es/concepts/signing","pageMetadata":{"title":"Firmas","description":"Cómo se construye la firma de un webhook, y cómo verificarla.","href":"/es/concepts/signing"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Cómo se construye la firma de un webhook, y cómo verificarla.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,em:`em`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`Listo manda los webhooks a una URL que tú le diste, sin ninguna credencial en la\npetición. La firma es la credencial. Es lo que te dice que un evento vino de\nListo, llegó sin alteraciones, y no es uno que alguien capturó antes y volvió a\nmandar.`}),`\n`,_jsx(_components.p,{children:`Cada evento lleva un encabezado:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`http`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`http`,children:_jsxs(_components.code,{language:`http`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`X-Listo-Signature`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` t=1753728063,v1=8f2c9d4e...`})]}),`\n`]})})}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`t`}),` es la hora Unix, en segundos, en la que se firmó el evento.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`v1`}),` es un HMAC-SHA256 en hexadecimal, con tu secreto de firma como llave,\nsobre la cadena `,_jsx(_components.code,{children:`\"\u003ct>.\u003craw body>\"`}),`: el valor de `,_jsx(_components.code,{children:`t`}),`, un punto, y el cuerpo de\nla petición tal como llegó.`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`Fíjate en que `,_jsx(_components.code,{children:`t`}),` va `,_jsx(_components.em,{children:`dentro`}),` de la cadena que se firma, no nada más al lado.\nAhí está toda la diferencia contra un HMAC simple del cuerpo: uno simple sigue\nsiendo válido para siempre, así que cualquiera que haya visto una sola petición\nválida podría reenviarla cuando se le antojara. Meter la marca de tiempo dentro\ndel resumen obliga a que una repetición o conserve el `,_jsx(_components.code,{children:`t`}),` original, y caiga\nfuera de la ventana de abajo, o lo cambie, e invalide la firma.`]}),`\n`,_jsx(Heading,{level:`2`,id:`cómo-verificar-una`,children:`Cómo verificar una`}),`\n`,_jsx(CodeBlock,{filename:`verify_webhook_signature.rb`,numberOfLines:`66`,language:`ruby`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`ruby`,children:_jsxs(_components.code,{language:`ruby`,numberOfLines:`66`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Verifies the signature on an incoming Listo webhook before trusting a byte of`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# it. Reads the raw request body on stdin, the way your web framework hands it`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# to you, and refuses anything that does not check out.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`#`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# LISTO_SIGNATURE='t=...,v1=...' LISTO_WEBHOOK_SECRETS=whsec_a,whsec_b \\\\`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# ruby verify_webhook_signature.rb \u003c body.json`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`#`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`require`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"json\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`require`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"openssl\"`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# The window a signature stays good for, matching the one Listo signs against.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# It is what stops a request someone captured from being replayed at you later.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`TOLERANCE_SECONDS`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 300`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:\"# `secrets` is a LIST because a rotation has two secrets live at once: accept\"})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# either while you swap over, then drop the old one.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` listo_signature_valid?`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`payload`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`header`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`secrets`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`now:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` Time`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`now`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` match`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D16969`},children:` /`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-light-font-weight\":`bold`,\"--shiki-dark\":`#D7BA7D`,\"--shiki-dark-font-weight\":`inherit`},children:`\\\\A`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D16969`},children:`t=(`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-light-font-weight\":`bold`,\"--shiki-dark\":`#D7BA7D`,\"--shiki-dark-font-weight\":`inherit`},children:`\\\\d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D16969`},children:`+),v1=(`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-light-font-weight\":`bold`,\"--shiki-dark\":`#D7BA7D`,\"--shiki-dark-font-weight\":`inherit`},children:`\\\\h`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D16969`},children:`+)`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-light-font-weight\":`bold`,\"--shiki-dark\":`#D7BA7D`,\"--shiki-dark-font-weight\":`inherit`},children:`\\\\z`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D16969`},children:`/`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`match`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(header.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`to_s`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` false`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` match.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`nil?`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` timestamp`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` match[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`to_i`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` signature`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` match[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`2`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # Checked in BOTH directions. A timestamp far in the past is the replay this`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # scheme exists to stop; one far in the future is the same attack against a`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # clock nobody looked at.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` false`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (now.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`to_i`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` -`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` timestamp).`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`abs`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` >`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` TOLERANCE_SECONDS`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` secrets.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`any?`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` do`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` |`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`secret`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`|`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` expected`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` OpenSSL`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#4EC9B0`},children:`::`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`HMAC`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`hexdigest`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"SHA256\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, secret, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`#{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`timestamp`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`.`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`#{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`payload`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` OpenSSL`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`secure_compare`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(expected, signature)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` end`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`end`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# The RAW bytes, before any JSON parsing. Parsing and re-serializing changes`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# them (key order, escapes, whitespace) and the signature covers what was sent,`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# not what your JSON library would have sent.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`payload`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` $stdin`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`read`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`header`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` ENV`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`fetch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"LISTO_SIGNATURE\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`nil`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`secrets`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` ENV`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`fetch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"LISTO_WEBHOOK_SECRETS\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`).`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`split`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\",\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`unless`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` listo_signature_valid?`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(payload, header, secrets)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # Answer 400 and stop. Do not parse it, do not act on it, do not log it as an`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # event you received.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` abort`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"signature rejected\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`end`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`event`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` JSON`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`parse`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(payload)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:\"# Events arrive at least once and in no guaranteed order, so treat `id` as the\"})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# thing you deduplicate on and the object's own timestamps as the thing you`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# order by. Answer 2xx quickly and do the work afterwards.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`puts`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`#{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`event[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"type\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`]`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` #{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`event[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"id\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`]`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`case`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` event[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`when`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"delivery.status_changed\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"delivery.updated\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` delivery`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` event[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"data\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` puts`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"order `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`#{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`delivery[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"external_id\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`]`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` is `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`#{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`delivery[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"status\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`]`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`when`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"delivery.courier_location\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` location`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` event.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`dig`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"data\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"location\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` puts`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"courier at `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`#{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`location[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"lat\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`]`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`,`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`#{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`location[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"lng\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`]`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`else`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # A new type is an additive change, so ignore what you do not recognise`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # rather than failing on it.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` puts`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"ignored\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`end`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Cuatro reglas, y cada una es una forma de que la verificación esté mal mientras\naparenta estar bien.`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Firma los bytes tal como llegaron.`}),` Sobre lo que llegó por el cable, antes de\ncualquier parseo de JSON. Parsear y volver a serializar cambia los bytes, porque\ntu librería de JSON tiene sus propias ideas sobre el orden de las llaves, las\nsecuencias de escape y los espacios, y la firma cubre lo que se mandó, no lo que\ntu librería habría mandado. Casi cualquier framework web te da el cuerpo sin\nprocesar si se lo pides; averigua cómo lo hace el tuyo antes de escribir la\nverificación.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Revisa la marca de tiempo en las dos direcciones.`}),` Rechaza cualquier cosa con\nmás de cinco minutos de antigüedad, que es la repetición que este esquema existe\npara frenar, `,_jsx(_components.em,{children:`y`}),` cualquier cosa con más de cinco minutos hacia el futuro.\nSaltarte la segunda mitad le regala a un atacante una ventana arbitrariamente\nlarga con solo escoger un `,_jsx(_components.code,{children:`t`}),` grande.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Compara en tiempo constante.`}),` Usa la comparación de tiempo constante de tu\nlenguaje, no `,_jsx(_components.code,{children:`==`}),`. Una comparación que se corta en el primer byte distinto\nfiltra qué tanto acertó el intento, y con eso basta para ir sacando una firma\nválida byte por byte.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Falla cerrado.`}),` Un encabezado mal formado, un encabezado ausente, una marca\nde tiempo que no se puede leer y una firma que no coincide son todos la misma\nrespuesta: no es auténtico. Rechaza con un `,_jsx(_components.code,{children:`400`}),`, y no parsees ni actúes sobre\nel cuerpo. Nunca dejes que el verificador lance una excepción; una excepción en\nun verificador es un `,_jsx(_components.code,{children:`500`}),` donde iba un rechazo.`]}),`\n`,_jsx(Heading,{level:`2`,id:`cómo-rotar-un-secreto`,children:`Cómo rotar un secreto`}),`\n`,_jsx(_components.p,{children:`Puedes tener dos secretos vivos al mismo tiempo, y eso es lo que hace posible\nuna rotación sin perder eventos. Listo firma con el principal; tú aceptas\ncualquiera de los dos.`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Agrega un segundo secreto`}),` en el\n`,_jsx(_components.a,{href:`https://partners.listo.delivery`,children:`panel de socios`}),`. Todavía no cambia nada:\nListo sigue firmando con el primero.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Enséñale los dos a tu verificador.`}),` Por eso la verificación de arriba\nrecibe una `,_jsx(_components.em,{children:`lista`}),`: acepta un evento que valide con cualquiera de los dos.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Promueve el nuevo secreto.`}),` Listo empieza a firmar con él. Tu endpoint\nsigue funcionando durante el cambio, porque ya acepta los dos.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Quita el viejo`}),`, en el panel y en tu propia configuración.`]}),`\n`]}),`\n`,_jsx(_components.p,{children:`Hazlo en ese orden. Si promueves antes del paso 2, cada evento en vuelo lo\nrechaza un endpoint que nunca ha visto el secreto nuevo.`}),`\n`,_jsxs(Warning,{children:[_jsx(_components.p,{children:_jsx(_components.strong,{children:`Un secreto es un secreto`})}),_jsx(_components.p,{children:`Guarda los secretos de firma como guardas las contraseñas: del lado del\nservidor, fuera de tu repositorio, fuera de cualquier cosa que alcance un\nnavegador. Quien tenga uno puede falsificar un evento que tu verificador va a\naceptar, que es lo mismo que poder decirle a tu sistema que un pedido se\nentregó.`})]}),`\n`,_jsx(Heading,{level:`2`,id:`cada-modo-tiene-sus-propios-secretos`,children:`Cada modo tiene sus propios secretos`}),`\n`,_jsx(_components.p,{children:`El mundo real y el de prueba tienen cada uno su URL de endpoint y su secreto de\nfirma. Un secreto de un modo nunca valida un evento del otro, y eso es lo que\nimpide que un despliegue de staging pueda aceptar tráfico de producción. Rótalos\npor separado.`}),`\n`,_jsxs(_components.p,{children:[`Poner todo esto a trabajar, incluyendo cómo responder, cómo deduplicar y cómo\nfuncionan los reintentos, es\n`,_jsx(_components.a,{href:`/es/guides/webhooks`,children:`recibe y verifica webhooks`}),`.`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Firmas","description":"Cómo se construye la firma de un webhook, y cómo verificarla.","href":"/es/concepts/signing"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Cómo verificar una","slug":"cómo-verificar-una","depth":2,"children":[]},{"title":"Cómo rotar un secreto","slug":"cómo-rotar-un-secreto","depth":2,"children":[]},{"title":"Cada modo tiene sus propios secretos","slug":"cada-modo-tiene-sus-propios-secretos","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"listo-c5a11a00","siteName":"Listo Partner API","title":"Firmas - Listo Partner API","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{"en":{"href":"/en/concepts/signing","matchLevel":1},"es":{"href":"/es/concepts/signing","matchLevel":0}}},"lastModified":"2026-11-07T01:49:02.582Z","originalFileLocation":"es/concepts/signing.mdx","locale":"es"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Cómo se construye la firma de un webhook, y cómo verificarla.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Listo Partner API\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/listo-c5a11a00/GMBEN5uWEX-r6cRJ/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/listo-c5a11a00/GMBEN5uWEX-r6cRJ/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/listo-c5a11a00/GMBEN5uWEX-r6cRJ/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/listo-c5a11a00/GMBEN5uWEX-r6cRJ/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/listo-c5a11a00/GMBEN5uWEX-r6cRJ/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/listo-c5a11a00/GMBEN5uWEX-r6cRJ/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/listo-c5a11a00/GMBEN5uWEX-r6cRJ/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/listo-c5a11a00/GMBEN5uWEX-r6cRJ/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/listo-c5a11a00/GMBEN5uWEX-r6cRJ/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Firmas - Listo Partner API\">\u003cmeta data-mint-head property=\"og:description\" content=\"Cómo se construye la firma de un webhook, y cómo verificarla.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Listo Partner API\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.listo.delivery/es/concepts/signing\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://listo-c5a11a00.mintlify.site/_mintlify/api/og/v2?title=Firmas\u0026amp;description=C%C3%B3mo+se+construye+la+firma+de+un+webhook%2C+y+c%C3%B3mo+verificarla.\u0026amp;theme=77fcfc9066d8b9eb9850b729\u0026amp;signature=f49029d126ced7c2f2529db0c1989f15507fae991b8eadb0f973b7bc59c7db42\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Firmas - Listo Partner API\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Cómo se construye la firma de un webhook, y cómo verificarla.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://listo-c5a11a00.mintlify.site/_mintlify/api/og/v2?title=Firmas\u0026amp;description=C%C3%B3mo+se+construye+la+firma+de+un+webhook%2C+y+c%C3%B3mo+verificarla.\u0026amp;theme=77fcfc9066d8b9eb9850b729\u0026amp;signature=f49029d126ced7c2f2529db0c1989f15507fae991b8eadb0f973b7bc59c7db42\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/listo-c5a11a00/GMBEN5uWEX-r6cRJ/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Listo Partner API\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#15171C\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.listo.delivery/es/concepts/signing\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/es/concepts/signing.md\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"es\" href=\"https://docs.listo.delivery/es/concepts/signing\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"en\" href=\"https://docs.listo.delivery/en/concepts/signing\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"x-default\" href=\"https://docs.listo.delivery/en/concepts/signing\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.listo.delivery/#organization\",\"name\":\"Listo Partner API\",\"url\":\"https://docs.listo.delivery\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/listo-c5a11a00/mreCwXzcEA2bSZog/logo/light.svg?fit=max\u0026auto=format\u0026n=mreCwXzcEA2bSZog\u0026q=85\u0026s=da2b28d464dc6987329dfd5971085dd7\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.listo.delivery#website\",\"name\":\"Listo Partner API\",\"url\":\"https://docs.listo.delivery\",\"publisher\":{\"@id\":\"https://docs.listo.delivery/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.listo.delivery/es/concepts/signing#webpage\",\"url\":\"https://docs.listo.delivery/es/concepts/signing\",\"name\":\"Firmas\",\"description\":\"Cómo se construye la firma de un webhook, y cómo verificarla.\",\"dateModified\":\"2026-11-07T01:49:02.582Z\",\"isPartOf\":{\"@id\":\"https://docs.listo.delivery#website\"},\"breadcrumb\":{\"@id\":\"https://docs.listo.delivery/es/concepts/signing#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.listo.delivery/es/concepts/signing#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Conceptos\",\"item\":\"https://docs.listo.delivery/es/concepts/money\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Firmas\",\"item\":\"https://docs.listo.delivery/es/concepts/signing\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.listo.delivery/es/concepts/signing#article\",\"headline\":\"Firmas\",\"name\":\"Firmas\",\"description\":\"Cómo se construye la firma de un webhook, y cómo verificarla.\",\"url\":\"https://docs.listo.delivery/es/concepts/signing\",\"mainEntityOfPage\":{\"@id\":\"https://docs.listo.delivery/es/concepts/signing#webpage\"},\"dateModified\":\"2026-11-07T01:49:02.582Z\",\"publisher\":{\"@id\":\"https://docs.listo.delivery/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.listo.delivery#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Listo Partner API\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Listo Partner API","nav":{"global":null,"languages":[{"language":"en","default":true,"navbar":{"links":[{"href":"https://status.listo.delivery","label":"Status"}]},"pages":[{"title":"en","href":"/en/concepts/signing"}]},{"language":"es","navbar":{"links":[{"href":"https://status.listo.delivery","label":"Estado del servicio"}]},"groups":[{"group":"Primeros pasos","pages":[{"title":"Inicio rápido","href":"/es/quickstart"}]},{"group":"Guías","pages":[{"title":"Cotiza y crea un envío","href":"/es/guides/quote-and-create"},{"title":"Recibe y verifica webhooks","href":"/es/guides/webhooks"},{"title":"Depurar tu integración","href":"/es/guides/debugging"},{"title":"Construye con IA","href":"/es/guides/build-with-ai"},{"title":"Fondea tu saldo y retira","href":"/es/guides/balance-and-withdrawals"},{"title":"Sal a producción","href":"/es/guides/go-live"},{"title":"Conecta un restaurante que ya usa Listo","sidebarTitle":"Conecta una cuenta existente","href":"/es/guides/connect-existing-account"},{"title":"Plan y cobro","href":"/es/guides/plan-and-billing"},{"title":"Conecta Claude, Cursor o Codex","href":"/es/guides/connect-ai-client"}]},{"group":"Errores","expanded":false,"pages":[{"title":"Errores","href":"/es/errors/index"},{"title":"account_exists","href":"/es/errors/account_exists"},{"title":"address_not_found","href":"/es/errors/address_not_found"},{"title":"address_undeliverable","href":"/es/errors/address_undeliverable"},{"title":"cancel_failed","href":"/es/errors/cancel_failed"},{"title":"card_below_minimum","href":"/es/errors/card_below_minimum"},{"title":"card_not_ready","href":"/es/errors/card_not_ready"},{"title":"cash_over_cap","href":"/es/errors/cash_over_cap"},{"title":"charge_in_progress","href":"/es/errors/charge_in_progress"},{"title":"code_expired","href":"/es/errors/code_expired"},{"title":"console_access_required","href":"/es/errors/console_access_required"},{"title":"event_not_resendable","href":"/es/errors/event_not_resendable"},{"title":"idempotency_conflict","href":"/es/errors/idempotency_conflict"},{"title":"insufficient_balance","href":"/es/errors/insufficient_balance"},{"title":"internal_error","href":"/es/errors/internal_error"},{"title":"invalid_api_key","href":"/es/errors/invalid_api_key"},{"title":"no_couriers_available","href":"/es/errors/no_couriers_available"},{"title":"not_cancellable","href":"/es/errors/not_cancellable"},{"title":"not_editable","href":"/es/errors/not_editable"},{"title":"not_found","href":"/es/errors/not_found"},{"title":"not_reactivatable","href":"/es/errors/not_reactivatable"},{"title":"not_refundable","href":"/es/errors/not_refundable"},{"title":"not_reschedulable","href":"/es/errors/not_reschedulable"},{"title":"not_retriable","href":"/es/errors/not_retriable"},{"title":"order_too_large","href":"/es/errors/order_too_large"},{"title":"out_of_service_area","href":"/es/errors/out_of_service_area"},{"title":"payout_account_not_ready","href":"/es/errors/payout_account_not_ready"},{"title":"pickup_point_pending","href":"/es/errors/pickup_point_pending"},{"title":"plan_ended","href":"/es/errors/plan_ended"},{"title":"plan_required","href":"/es/errors/plan_required"},{"title":"provider_unavailable","href":"/es/errors/provider_unavailable"},{"title":"quote_consumed","href":"/es/errors/quote_consumed"},{"title":"quote_expired","href":"/es/errors/quote_expired"},{"title":"rate_limited","href":"/es/errors/rate_limited"},{"title":"read_only_key","href":"/es/errors/read_only_key"},{"title":"refund_amount_too_large","href":"/es/errors/refund_amount_too_large"},{"title":"resend_limit_reached","href":"/es/errors/resend_limit_reached"},{"title":"same_day_below_minimum","href":"/es/errors/same_day_below_minimum"},{"title":"same_day_cap_exceeded","href":"/es/errors/same_day_cap_exceeded"},{"title":"test_webhook_limit_reached","href":"/es/errors/test_webhook_limit_reached"},{"title":"unsupported_country","href":"/es/errors/unsupported_country"},{"title":"validation_failed","href":"/es/errors/validation_failed"},{"title":"webhook_endpoint_not_configured","href":"/es/errors/webhook_endpoint_not_configured"}]},{"group":"Referencia","pages":[{"group":"Saldo","pages":[{"title":"Consulta tu saldo prepagado","deprecated":null,"version":null,"sidebarTitle":"Consulta tu saldo prepagado","openapi":"/openapi/es.yaml get /v1/balance","href":"/es/api-reference/balance/read-your-prepaid-balance"},{"title":"Consulta el saldo de una tienda","deprecated":null,"version":null,"sidebarTitle":"Consulta el saldo de una tienda","openapi":"/openapi/es.yaml get /v1/stores/{store_id}/balance","href":"/es/api-reference/balance/read-a-stores-balance"}]},{"group":"Conexión de cuenta","pages":[{"title":"Pide a un restaurante que conecte la cuenta que ya tiene en Listo","deprecated":null,"version":null,"sidebarTitle":"Pide a un restaurante que conecte la cuenta que ya tiene en Listo","openapi":"/openapi/es.yaml post /v1/connect_requests","href":"/es/api-reference/account-connection/ask-a-restaurant-to-connect-its-account"},{"title":"Canjea una aprobación por la tienda","deprecated":null,"version":null,"sidebarTitle":"Canjea una aprobación por la tienda","openapi":"/openapi/es.yaml post /v1/connections","href":"/es/api-reference/account-connection/exchange-an-approval-for-the-store"}]},{"group":"Envíos","pages":[{"title":"Lista envíos","deprecated":null,"version":null,"sidebarTitle":"Lista envíos","openapi":"/openapi/es.yaml get /v1/deliveries","href":"/es/api-reference/deliveries/list-deliveries"},{"title":"Crea un envío","deprecated":null,"version":null,"sidebarTitle":"Crea un envío","openapi":"/openapi/es.yaml post /v1/deliveries","href":"/es/api-reference/deliveries/create-a-delivery"},{"title":"Cancela un envío","deprecated":null,"version":null,"sidebarTitle":"Cancela un envío","openapi":"/openapi/es.yaml post /v1/deliveries/{delivery_id}/cancellations","href":"/es/api-reference/deliveries/cancel-a-delivery"},{"title":"Reembolsa un envío","deprecated":null,"version":null,"sidebarTitle":"Reembolsa un envío","openapi":"/openapi/es.yaml post /v1/deliveries/{delivery_id}/refunds","href":"/es/api-reference/deliveries/refund-a-delivery"},{"title":"Reintenta un despacho fallido","deprecated":null,"version":null,"sidebarTitle":"Reintenta un despacho fallido","openapi":"/openapi/es.yaml post /v1/deliveries/{delivery_id}/retries","href":"/es/api-reference/deliveries/retry-a-failed-dispatch"},{"title":"Obtén un envío","deprecated":null,"version":null,"sidebarTitle":"Obtén un envío","openapi":"/openapi/es.yaml get /v1/deliveries/{id}","href":"/es/api-reference/deliveries/fetch-a-delivery"},{"title":"Actualiza un envío","deprecated":null,"version":null,"sidebarTitle":"Actualiza un envío","openapi":"/openapi/es.yaml patch /v1/deliveries/{id}","href":"/es/api-reference/deliveries/update-a-delivery"}]},{"group":"Eventos","pages":[{"title":"Lista tus eventos de webhook","deprecated":null,"version":null,"sidebarTitle":"Lista tus eventos de webhook","openapi":"/openapi/es.yaml get /v1/events","href":"/es/api-reference/events/list-your-webhook-events"},{"title":"Reenvía un evento de webhook","deprecated":null,"version":null,"sidebarTitle":"Reenvía un evento de webhook","openapi":"/openapi/es.yaml post /v1/events/{event_id}/resend","href":"/es/api-reference/events/send-a-webhook-event-again"},{"title":"Obtén un evento de webhook","deprecated":null,"version":null,"sidebarTitle":"Obtén un evento de webhook","openapi":"/openapi/es.yaml get /v1/events/{id}","href":"/es/api-reference/events/retrieve-a-webhook-event"},{"title":"Envía un webhook de prueba","deprecated":null,"version":null,"sidebarTitle":"Envía un webhook de prueba","openapi":"/openapi/es.yaml post /v1/test_webhooks","href":"/es/api-reference/events/send-a-test-webhook"}]},{"group":"Historial","pages":[{"title":"Lista tus movimientos del historial","deprecated":null,"version":null,"sidebarTitle":"Lista tus movimientos del historial","openapi":"/openapi/es.yaml get /v1/ledger","href":"/es/api-reference/ledger/list-your-ledger-entries"},{"title":"Lista los movimientos del historial de una tienda","deprecated":null,"version":null,"sidebarTitle":"Lista los movimientos del historial de una tienda","openapi":"/openapi/es.yaml get /v1/stores/{store_id}/ledger","href":"/es/api-reference/ledger/list-a-stores-ledger-entries"}]},{"group":"Autenticación","pages":[{"title":"Verifica que tu llave de API funciona","deprecated":null,"version":null,"sidebarTitle":"Verifica que tu llave de API funciona","openapi":"/openapi/es.yaml get /v1/ping","href":"/es/api-reference/authentication/check-that-your-api-key-works"}]},{"group":"Cotizaciones","pages":[{"title":"Cotiza un envío","deprecated":null,"version":null,"sidebarTitle":"Cotiza un envío","openapi":"/openapi/es.yaml post /v1/quotes","href":"/es/api-reference/quotes/price-a-delivery"}]},{"group":"Registro de solicitudes","pages":[{"title":"Lista tu registro de solicitudes","deprecated":null,"version":null,"sidebarTitle":"Lista tu registro de solicitudes","openapi":"/openapi/es.yaml get /v1/request_logs","href":"/es/api-reference/request-logs/list-your-request-log"},{"title":"Obtén una entrada del registro de solicitudes","deprecated":null,"version":null,"sidebarTitle":"Obtén una entrada del registro de solicitudes","openapi":"/openapi/es.yaml get /v1/request_logs/{id}","href":"/es/api-reference/request-logs/retrieve-a-request-log-entry"}]},{"group":"Tiendas","pages":[{"title":"Lista tus tiendas","deprecated":null,"version":null,"sidebarTitle":"Lista tus tiendas","openapi":"/openapi/es.yaml get /v1/stores","href":"/es/api-reference/stores/list-your-stores"},{"title":"Crea una tienda","deprecated":null,"version":null,"sidebarTitle":"Crea una tienda","openapi":"/openapi/es.yaml post /v1/stores","href":"/es/api-reference/stores/create-a-store"},{"title":"Obtén una tienda","deprecated":null,"version":null,"sidebarTitle":"Obtén una tienda","openapi":"/openapi/es.yaml get /v1/stores/{id}","href":"/es/api-reference/stores/fetch-a-store"},{"title":"Actualiza una tienda","deprecated":null,"version":null,"sidebarTitle":"Actualiza una tienda","openapi":"/openapi/es.yaml patch /v1/stores/{id}","href":"/es/api-reference/stores/update-a-store"},{"title":"Invita al dueño de una tienda","deprecated":null,"version":null,"sidebarTitle":"Invita al dueño de una tienda","openapi":"/openapi/es.yaml post /v1/stores/{store_id}/owner","href":"/es/api-reference/stores/invite-a-store-owner"},{"title":"Reactiva el plan de una tienda","deprecated":null,"version":null,"sidebarTitle":"Reactiva el plan de una tienda","openapi":"/openapi/es.yaml post /v1/stores/{store_id}/plan","href":"/es/api-reference/stores/reactivate-a-stores-plan"},{"title":"Cancela el plan de una tienda","deprecated":null,"version":null,"sidebarTitle":"Cancela el plan de una tienda","openapi":"/openapi/es.yaml post /v1/stores/{store_id}/plan_cancellation","href":"/es/api-reference/stores/cancel-a-stores-plan"},{"title":"Deshaz la cancelación del plan de una tienda","deprecated":null,"version":null,"sidebarTitle":"Deshaz la cancelación del plan de una tienda","openapi":"/openapi/es.yaml delete /v1/stores/{store_id}/plan_cancellation","href":"/es/api-reference/stores/undo-a-stores-plan-cancellation"}]},{"group":"Alta de cobros con tarjeta","pages":[{"title":"Inicia el alta para cobros con tarjeta de una tienda","deprecated":null,"version":null,"sidebarTitle":"Inicia el alta para cobros con tarjeta de una tienda","openapi":"/openapi/es.yaml post /v1/stores/{store_id}/stripe_onboarding","href":"/es/api-reference/card-onboarding/start-card-onboarding-for-a-store"},{"title":"Consulta la disponibilidad para cobrar con tarjeta de una tienda","deprecated":null,"version":null,"sidebarTitle":"Consulta la disponibilidad para cobrar con tarjeta de una tienda","openapi":"/openapi/es.yaml get /v1/stores/{store_id}/stripe_status","href":"/es/api-reference/card-onboarding/read-a-stores-card-readiness"},{"title":"Inicia el alta para cobros con tarjeta de tu empresa","deprecated":null,"version":null,"sidebarTitle":"Inicia el alta para cobros con tarjeta de tu empresa","openapi":"/openapi/es.yaml post /v1/stripe_onboarding","href":"/es/api-reference/card-onboarding/start-card-onboarding-for-your-company"},{"title":"Consulta la disponibilidad para cobrar con tarjeta de tu empresa","deprecated":null,"version":null,"sidebarTitle":"Consulta la disponibilidad para cobrar con tarjeta de tu empresa","openapi":"/openapi/es.yaml get /v1/stripe_status","href":"/es/api-reference/card-onboarding/read-your-companys-card-readiness"}]},{"group":"Entregas de webhook","pages":[{"title":"Lista los intentos de entrega de webhook","deprecated":null,"version":null,"sidebarTitle":"Lista los intentos de entrega de webhook","openapi":"/openapi/es.yaml get /v1/webhook_deliveries","href":"/es/api-reference/webhook-deliveries/list-webhook-delivery-attempts"}]},{"group":"Retiros","pages":[{"title":"Lista tus retiros","deprecated":null,"version":null,"sidebarTitle":"Lista tus retiros","openapi":"/openapi/es.yaml get /v1/withdrawals","href":"/es/api-reference/withdrawals/list-your-withdrawals"},{"title":"Solicita un retiro","deprecated":null,"version":null,"sidebarTitle":"Solicita un retiro","openapi":"/openapi/es.yaml post /v1/withdrawals","href":"/es/api-reference/withdrawals/request-a-withdrawal"},{"title":"Obtén un retiro","deprecated":null,"version":null,"sidebarTitle":"Obtén un retiro","openapi":"/openapi/es.yaml get /v1/withdrawals/{id}","href":"/es/api-reference/withdrawals/fetch-a-withdrawal"}]},{"group":"Webhooks","pages":[{"title":"A delivery reached a new status","version":null,"deprecated":null,"sidebarTitle":"Un envío llegó a un nuevo estado","openapi":"/openapi/es.yaml webhook delivery.status_changed","href":"/es/api-reference/webhooks/a-delivery-reached-a-new-status"},{"title":"A delivery changed without changing status","version":null,"deprecated":null,"sidebarTitle":"Un envío cambió sin cambiar de estado","openapi":"/openapi/es.yaml webhook delivery.updated","href":"/es/api-reference/webhooks/a-delivery-changed-without-changing-status"},{"title":"The courier moved","version":null,"deprecated":null,"sidebarTitle":"El repartidor se movió","openapi":"/openapi/es.yaml webhook delivery.courier_location","href":"/es/api-reference/webhooks/the-courier-moved"},{"title":"A withdrawal was settled","version":null,"deprecated":null,"sidebarTitle":"Un retiro se liquidó","openapi":"/openapi/es.yaml webhook withdrawal.updated","href":"/es/api-reference/webhooks/a-withdrawal-was-settled"},{"title":"A store changed","version":null,"deprecated":null,"sidebarTitle":"Una tienda cambió","openapi":"/openapi/es.yaml webhook store.updated","href":"/es/api-reference/webhooks/a-store-changed"},{"title":"A restaurant connected its existing account to you","version":null,"deprecated":null,"sidebarTitle":"Un restaurante conectó la cuenta de Listo que ya tenía contigo","openapi":"/openapi/es.yaml webhook store.connected","href":"/es/api-reference/webhooks/a-restaurant-connected-its-existing-account-to-you"}]}]},{"group":"Conceptos","pages":[{"title":"El modelo de dinero","href":"/es/concepts/money"},{"title":"De dónde viene un envío","href":"/es/concepts/delivery-origin"},{"title":"Modo de prueba","description":"Qué hace distinto una llave de prueba, y qué no.","href":"/es/concepts/test-mode"},{"title":"Firmas","href":"/es/concepts/signing"},{"title":"Efectivo en la puerta","description":"Cómo se le cobra en efectivo al cliente en la entrega, y en qué se liquida.","href":"/es/concepts/cash-at-the-door"}]},{"group":"Historial de cambios","pages":[{"title":"Historial de cambios","href":"/es/changelog"}]},{"group":"Legal","pages":[{"title":"Términos para Partners","url":"https://listo.delivery/terminos-partners","href":"/es/terms-for-partners"}]}]}]},"basePath":"","title":"Firmas - Listo Partner API","buildId":"dpl_8LJbrAiZvr1K98WQNZXCyY5AvT34","deploymentId":"dpl_8LJbrAiZvr1K98WQNZXCyY5AvT34","dynamics":[],"chunks":[]}