Send idempotent Zinc API requests to safely retry orders without creating duplicates.
Every order Zinc places spends real money. An idempotency key is your guarantee that one logical purchase results in one charge — no matter how many times the request is sent.Use one on every order. It’s the only thing standing between a flaky network, a buggy retry, or an over-eager client and a duplicate order on a real card.
Include an idempotency_key in your request body. It can be any string up to 36 characters — a UUID is the right choice. Zinc enforces uniqueness on this key, so at most one order will ever exist for it, no matter how many times you send the same request.Use a fresh key for each new order. The same key always means the same order.
Retry on network problems and Zinc service errors. Timeouts, connection resets, and 5xx responses are usually transient. Use the same idempotency key and back off between attempts (e.g. 1s, 2s, 4s, capped at a few tries).
Don’t retry on errors caused by your request. Bad input, bad auth, insufficient funds — these will fail the same way next time. Fix the cause, then submit a new order with a new key.
An already_exists response on a retry means the original attempt succeeded. Treat it as success and stop retrying.
Don’t retry every error. Retrying validation, auth, or payment errors won’t make them go away. And if you “fix” the loop by changing the idempotency key on each attempt, you’ll create duplicate orders the moment Zinc recovers.
Treating every non-success response as retryable hides bugs in your integration. Auth, validation, and payment errors are deterministic — the next attempt will fail the same way.
key attempt 1key-retry attempt 2 (new key, new order)key_attempt_2 attempt 3 (new key, new order)newUuid() attempt 4 (new key, new order)`${key}-${Date.now()}` attempt N (new key, new order)
The whole point is that the key does not change between attempts of the same logical operation. If you append a counter, a timestamp, an attempt number, or generate a fresh UUID per retry, you’re creating N orders on N retries. Send the same string every time.
An already_exists response on a retry means the original request succeeded. Surfacing it as an error — or retrying with a new key — turns a successful order into a duplicate.
Generate the key, write it to your database alongside the pending order, then call Zinc. A key that lives only in memory is a key you can’t retry with if your process crashes mid-call.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Zinc Docs","colors":{"primary":"#386DF0","light":"#FFFEF9","dark":"#292724"},"logo":{"light":"https://mintcdn.com/zinc/exQ2EzxrXSSg0dh-/logo/light.png?fit=max\u0026auto=format\u0026n=exQ2EzxrXSSg0dh-\u0026q=85\u0026s=633d13238d6799080400fbb91b9d08b7","dark":"https://mintcdn.com/zinc/exQ2EzxrXSSg0dh-/logo/dark.png?fit=max\u0026auto=format\u0026n=exQ2EzxrXSSg0dh-\u0026q=85\u0026s=2838196e697c37fe7cdfd161d33f0650","href":"https://zinc.com"},"favicon":"https://mintcdn.com/zinc/6WBnGJAdgAZ2bveD/favicon.svg?fit=max\u0026auto=format\u0026n=6WBnGJAdgAZ2bveD\u0026q=85\u0026s=ff98cf52a415bcea465dcad9a6720435","navbar":{"links":[{"href":"mailto:support@zinc.com","label":"Support"}],"primary":{"type":"button","label":"Dashboard","href":"https://app.zinc.com"}},"contextual":{"options":["copy","chatgpt","claude"],"display":"header"},"styling":{"latex":true},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"zinc","hasAudioNarration":false,"actualSubdomain":"zinc","customDomains":["www.zinc.com"],"gitSource":{"type":"github","owner":"zincio","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6ae12fbd86cea4b1941cd1d5","collectionId":"f145eba8-1239-4e4f-80c2-8aaca95fc2c7","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6ae12fbd86cea4b1941cd1d5"},"feedback":{"agentFeedback":true},"entitlements":{"AI_CHAT":{"status":"DISABLED"},"WEB_MCP":{"status":"DISABLED"},"NARRATION":{"status":"DISABLED"}},"buildId":"6ae12fbd86cea4b1941cd1d5","clientVersion":"0.0.4006","searchFilterCounts":[{"language":"default","tag":"API Reference","count":83},{"language":"default","tag":"Guides","count":22},{"language":"default","tag":"Orders","count":14},{"language":"default","tag":"Object Reference","count":13},{"language":"default","tag":"Objects","count":13},{"language":"default","tag":"Getting Started","count":11},{"language":"default","tag":"Cases","count":8},{"language":"default","tag":"Agent Sandbox","count":8},{"language":"default","tag":"Product Data","count":7},{"language":"default","tag":"Introduction","count":5}]},"assistantConfig":{},"basePath":"/docs","hasChatPermissions":false,"hasWebMcpPermissions":false,"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":"editor-v7-file-tree","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":"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":"pause-universal-search-reconcile","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":"per-site-search-delta","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":"editor-private-page-search","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":"editor-nav-generations","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":"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":"byok-sep-25","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":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-agent-model-picker","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","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":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":"#footer{display:none}:root{--primary:56 109 240;--primary-light:255 254 249;--primary-dark:41 39 36;--background-light:255 254 249;--background-dark:41 39 36;--grey-900:#29272480!important}"},{"filePath":"custom.css","content":"table th{text-align:left!important}.frame{background-color:rgba(255,254,249,.5)!important}.dark .frame{background-color:rgba(41,39,36,.25)!important}.frame [class*=bg-grid]{display:none!important}h3+.frame img,h3+.frame video{aspect-ratio:2048/1350!important;object-fit:contain;width:100%}"}],"page":{"pagePath":"v2/api-reference/introduction/idempotency","slug":"/v2/api-reference/introduction/idempotency","pageMetadata":{"title":"Idempotency","description":"Send idempotent Zinc API requests to safely retry orders without creating duplicates.","icon":"repeat-1","href":"/v2/api-reference/introduction/idempotency"},"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: \"Send idempotent Zinc API requests to safely retry orders without creating duplicates.\"\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={code:`code`,em:`em`,li:`li`,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:`Every order Zinc places spends real money. An idempotency key is your guarantee that one logical purchase results in one charge — no matter how many times the request is sent.`}),`\n`,_jsx(_components.p,{children:`Use one on every order. It’s the only thing standing between a flaky network, a buggy retry, or an over-eager client and a duplicate order on a real card.`}),`\n`,_jsx(Heading,{level:`2`,id:`how-it-works`,children:`How it works`}),`\n`,_jsxs(_components.p,{children:[`Include an `,_jsx(_components.code,{children:`idempotency_key`}),` in your request body. It can be any string up to 36 characters — a UUID is the right choice. Zinc enforces uniqueness on this key, so at most one order will ever exist for it, no matter how many times you send the same request.`]}),`\n`,_jsx(_components.p,{children:`Use a fresh key for each new order. The same key always means the same order.`}),`\n`,_jsx(Heading,{level:`2`,id:`behavior-on-retry`,children:`Behavior on retry`}),`\n`,_jsxs(_components.p,{children:[`If you send a request with a key that has already been used, Zinc returns an `,_jsx(_components.code,{children:`already_exists`}),` error rather than replaying the original response:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`json`,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:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`8`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"code\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"already_exists\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"message\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Order with idempotency key 'a3f1...' already exists\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"details\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"resource\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Order\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"identifier\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"a3f1c2d4-...\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`On a retry, this is `,_jsx(_components.strong,{children:`success, not failure`}),` — your original request got through. Look the order up by its id (or by `,_jsx(_components.code,{children:`metadata`}),`) and move on.`]}),`\n`,_jsx(Heading,{level:`2`,id:`example`,children:`Example`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`11`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`11`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` https://api.zinc.com/orders`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Authorization: Bearer \u003cyour_api_key>\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Content-Type: application/json\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"idempotency_key\": \"a3f1c2d4-7b8e-4a9f-9c1d-2e3f4a5b6c7d\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"products\": [`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` { \"url\": \"https://www.amazon.com/dp/B07JGBW826\", \"quantity\": 1 }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ],`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"shipping_address\": { ... },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"max_price\": 2300`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }'`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`If the call succeeds, store the returned order id. If it errors out, see below.`}),`\n`,_jsx(Heading,{level:`2`,id:`when-to-retry`,children:`When to retry`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Retry on network problems and Zinc service errors.`}),` Timeouts, connection resets, and `,_jsx(_components.code,{children:`5xx`}),` responses are usually transient. Use the `,_jsx(_components.strong,{children:`same`}),` idempotency key and back off between attempts (e.g. 1s, 2s, 4s, capped at a few tries).`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Don’t retry on errors caused by your request.`}),` Bad input, bad auth, insufficient funds — these will fail the same way next time. Fix the cause, then submit a new order with a new key.`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`An `,_jsx(_components.code,{children:`already_exists`}),` response on a retry means the original attempt succeeded. Treat it as success and stop retrying.`]}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Don’t retry every error.`}),` Retrying validation, auth, or payment errors won’t make them go away. And if you “fix” the loop by changing the idempotency key on each attempt, you’ll create duplicate orders the moment Zinc recovers.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`anti-patterns`,children:`Anti-patterns`}),`\n`,_jsx(_components.p,{children:`These are real patterns we’ve seen cause duplicate orders or hide real failures.`}),`\n`,_jsx(Heading,{level:`4`,id:`retrying-every-error`,children:`Retrying every error`}),`\n`,_jsx(_components.p,{children:`Treating every non-success response as retryable hides bugs in your integration. Auth, validation, and payment errors are deterministic — the next attempt will fail the same way.`}),`\n`,_jsx(Heading,{level:`4`,id:`changing-the-key-per-attempt`,children:`Changing the key per attempt`}),`\n`,_jsx(_components.p,{children:`Every one of these defeats idempotency:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`text`,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:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`6`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`key attempt 1`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`key-retry attempt 2 (new key, new order)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`key_attempt_2 attempt 3 (new key, new order)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`newUuid() attempt 4 (new key, new order)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:\"`${key}-${Date.now()}` attempt N (new key, new order)\"})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`The whole point is that the key does `,_jsx(_components.strong,{children:`not`}),` change between attempts of the same logical operation. If you append a counter, a timestamp, an attempt number, or generate a fresh UUID per retry, you’re creating N orders on N retries. Send the same string every time.`]}),`\n`,_jsx(Heading,{level:`4`,id:`treating-a-duplicate-key-response-as-failure`,children:`Treating a duplicate-key response as failure`}),`\n`,_jsxs(_components.p,{children:[`An `,_jsx(_components.code,{children:`already_exists`}),` response on a retry means the original request succeeded. Surfacing it as an error — or retrying with a new key — turns a successful order into a duplicate.`]}),`\n`,_jsx(Heading,{level:`4`,id:`not-persisting-the-key-before-sending-the-request`,children:`Not persisting the key before sending the request`}),`\n`,_jsxs(_components.p,{children:[`Generate the key, write it to your database alongside the pending order, `,_jsx(_components.em,{children:`then`}),` call Zinc. A key that lives only in memory is a key you can’t retry with if your process crashes mid-call.`]})]})}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":"Idempotency","description":"Send idempotent Zinc API requests to safely retry orders without creating duplicates.","icon":"repeat-1","href":"/v2/api-reference/introduction/idempotency"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"How it works","slug":"how-it-works","depth":2,"children":[]},{"title":"Behavior on retry","slug":"behavior-on-retry","depth":2,"children":[]},{"title":"Example","slug":"example","depth":2,"children":[]},{"title":"When to retry","slug":"when-to-retry","depth":2,"children":[]},{"title":"Anti-patterns","slug":"anti-patterns","depth":2,"children":[{"title":"Retrying every error","slug":"retrying-every-error","depth":4,"children":[]},{"title":"Changing the key per attempt","slug":"changing-the-key-per-attempt","depth":4,"children":[]},{"title":"Treating a duplicate-key response as failure","slug":"treating-a-duplicate-key-response-as-failure","depth":4,"children":[]},{"title":"Not persisting the key before sending the request","slug":"not-persisting-the-key-before-sending-the-request","depth":4,"children":[]}]}],"codeExamples":{}},"jsLinks":[],"subdomain":"zinc","siteName":"Zinc Docs","title":"Idempotency - Zinc Docs","navMaps":{"firstHrefInVersion":{"v1":{"href":"/v1/api-reference/introduction/idempotency","matchLevel":1},"v2 - 2026-10-26":{"href":"/v2/api-reference/introduction/idempotency","matchLevel":0}},"firstHrefInLanguage":{}},"lastModified":"2026-07-28T23:40:20.558Z","originalFileLocation":"v2/api-reference/introduction/idempotency.mdx"},"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=\"Send idempotent Zinc API requests to safely retry orders without creating duplicates.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Zinc Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/zinc/_LtPLM5Rgn46vKzY/_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=\"/docs/mintlify-assets/_mintlify/favicons/zinc/_LtPLM5Rgn46vKzY/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/zinc/_LtPLM5Rgn46vKzY/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/zinc/_LtPLM5Rgn46vKzY/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/zinc/_LtPLM5Rgn46vKzY/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/zinc/_LtPLM5Rgn46vKzY/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/zinc/_LtPLM5Rgn46vKzY/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/zinc/_LtPLM5Rgn46vKzY/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/zinc/_LtPLM5Rgn46vKzY/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Idempotency - Zinc Docs\">\u003cmeta data-mint-head property=\"og:description\" content=\"Send idempotent Zinc API requests to safely retry orders without creating duplicates.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Zinc Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://www.zinc.com/docs/v2/api-reference/introduction/idempotency\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://zinc.mintlify.app/_mintlify/api/og/v2?division=Getting+Started\u0026amp;title=Idempotency\u0026amp;description=Send+idempotent+Zinc+API+requests+to+safely+retry+orders+without+creating+duplicates.\u0026amp;theme=f2b55f0bf154012a40eb6c4a\u0026amp;signature=d6bee8d4de1f41b356f9d50796aa881808c7ea9c74327df74699a0d2412f6234\">\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=\"Idempotency - Zinc Docs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Send idempotent Zinc API requests to safely retry orders without creating duplicates.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://zinc.mintlify.app/_mintlify/api/og/v2?division=Getting+Started\u0026amp;title=Idempotency\u0026amp;description=Send+idempotent+Zinc+API+requests+to+safely+retry+orders+without+creating+duplicates.\u0026amp;theme=f2b55f0bf154012a40eb6c4a\u0026amp;signature=d6bee8d4de1f41b356f9d50796aa881808c7ea9c74327df74699a0d2412f6234\">\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=\"/docs/mintlify-assets/_mintlify/favicons/zinc/_LtPLM5Rgn46vKzY/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Zinc Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#386DF0\">\u003clink data-mint-head rel=\"canonical\" href=\"https://www.zinc.com/docs/v2/api-reference/introduction/idempotency\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/docs/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/docs/v2/api-reference/introduction/idempotency.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://www.zinc.com/#organization\",\"name\":\"Zinc Docs\",\"url\":\"https://www.zinc.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/zinc/exQ2EzxrXSSg0dh-/logo/light.png?fit=max\u0026auto=format\u0026n=exQ2EzxrXSSg0dh-\u0026q=85\u0026s=633d13238d6799080400fbb91b9d08b7\"}},{\"@type\":\"WebSite\",\"@id\":\"https://www.zinc.com/docs#website\",\"name\":\"Zinc Docs\",\"url\":\"https://www.zinc.com/docs\",\"publisher\":{\"@id\":\"https://www.zinc.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://www.zinc.com/docs/v2/api-reference/introduction/idempotency#webpage\",\"url\":\"https://www.zinc.com/docs/v2/api-reference/introduction/idempotency\",\"name\":\"Idempotency\",\"description\":\"Send idempotent Zinc API requests to safely retry orders without creating duplicates.\",\"dateModified\":\"2026-07-28T23:40:20.558Z\",\"isPartOf\":{\"@id\":\"https://www.zinc.com/docs#website\"},\"breadcrumb\":{\"@id\":\"https://www.zinc.com/docs/v2/api-reference/introduction/idempotency#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://www.zinc.com/docs/v2/api-reference/introduction/idempotency#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Getting Started\",\"item\":\"https://www.zinc.com/docs/v2/api-reference/introduction/authentication\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Idempotency\",\"item\":\"https://www.zinc.com/docs/v2/api-reference/introduction/idempotency\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://www.zinc.com/docs/v2/api-reference/introduction/idempotency#article\",\"headline\":\"Idempotency\",\"name\":\"Idempotency\",\"description\":\"Send idempotent Zinc API requests to safely retry orders without creating duplicates.\",\"url\":\"https://www.zinc.com/docs/v2/api-reference/introduction/idempotency\",\"mainEntityOfPage\":{\"@id\":\"https://www.zinc.com/docs/v2/api-reference/introduction/idempotency#webpage\"},\"dateModified\":\"2026-07-28T23:40:20.558Z\",\"publisher\":{\"@id\":\"https://www.zinc.com/#organization\"},\"isPartOf\":{\"@id\":\"https://www.zinc.com/docs#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Zinc Docs\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Zinc Docs","nav":{"global":null,"versions":[{"version":"v1","pages":[{"title":"v1","href":"/v1/api-reference/introduction/idempotency"}]},{"version":"v2 - 2026-10-26","default":true,"tabs":[{"tab":"Guides","pages":[{"title":"Guides","href":""}]},{"tab":"Changelog","pages":[{"title":"Changelog","href":"/changelog"}]},{"tab":"API Reference","groups":[{"group":"Getting Started","pages":[{"title":"Authentication","description":"Authenticate Zinc API requests with your client token and API key.","icon":"key","href":"/v2/api-reference/introduction/authentication"},{"title":"Idempotency","icon":"repeat-1","href":"/v2/api-reference/introduction/idempotency"},{"title":"Sandbox \u0026 Testing","description":"Test your Zinc API integration in the sandbox — place and simulate orders without buying anything.","icon":"flask-vial","href":"/v2/api-reference/introduction/sandbox"},{"title":"Error Handling","icon":"triangle-exclamation","href":"/v2/api-reference/introduction/error-handling"},{"title":"Webhooks","icon":"bell","href":"/v2/api-reference/introduction/webhooks"},{"title":"API Changelog","icon":"code-compare","href":"/v2/api-reference/introduction/api-changelog"}]},{"group":"Agent Sandbox","pages":[{"title":"Agent Sandbox","sidebarTitle":"Overview","icon":"robot","href":"/v2/api-reference/sandbox/overview"},{"title":"Mint a Sandbox Key","openapi":"versions/latest.json POST /sandbox/keys","href":"/v2/api-reference/sandbox/mint-sandbox-key"},{"title":"Agent Quickstart","openapi":"versions/latest.json GET /sandbox/quickstart","href":"/v2/api-reference/sandbox/get-agent-quickstart"},{"title":"Claim a Sandbox","openapi":"versions/latest.json POST /sandbox/claim","href":"/v2/api-reference/sandbox/claim-sandbox"},{"title":"Get Sandbox Status","openapi":"versions/latest.json GET /sandbox/status","href":"/v2/api-reference/sandbox/get-sandbox-status"}]},{"group":"Device Approval","pages":[{"title":"Start a Device Code","openapi":"versions/latest.json POST /device/code","href":"/v2/api-reference/device/start-device-code"},{"title":"Redeem a Device Code","openapi":"versions/latest.json POST /device/token","href":"/v2/api-reference/device/redeem-device-code"},{"title":"Describe a Device Code","openapi":"versions/latest.json GET /device/codes/{user_code}","href":"/v2/api-reference/device/describe-device-code"},{"title":"Approve a Device Code","openapi":"versions/latest.json POST /device/approve","href":"/v2/api-reference/device/approve-device-code"}]},{"group":"Search (Beta)","pages":[{"title":"Cross-Retailer Search","openapi":"versions/latest.json GET /search","href":"/v2/api-reference/search/cross-retailer"}]},{"group":"Orders","pages":[{"title":"Create Order","openapi":"versions/latest.json POST /orders","href":"/v2/api-reference/orders/create-order"},{"title":"List Orders","openapi":"versions/latest.json GET /orders","href":"/v2/api-reference/orders/list-orders"},{"title":"Get Order","openapi":"versions/latest.json GET /orders/{order_id}","href":"/v2/api-reference/orders/get-order"},{"title":"Get Order Timeline","openapi":"versions/latest.json GET /orders/{order_id}/timeline","href":"/v2/api-reference/orders/get-order-timeline"},{"title":"Cancel Order","openapi":"versions/latest.json POST /orders/{order_id}/cancel","href":"/v2/api-reference/orders/cancel-order"},{"title":"Order Tracking","icon":"truck-fast","href":"/v2/api-reference/orders/tracking"},{"title":"Get Public Tracking","openapi":"versions/latest.json GET /track/{order_id}","href":"/v2/api-reference/orders/get-public-tracking"},{"title":"Export Orders","openapi":"versions/latest.json GET /orders/export","href":"/v2/api-reference/orders/export-orders"},{"title":"The Products Array","icon":"boxes-stacked","href":"/v2/api-reference/orders/multiple-products-quantities"}]},{"group":"Bulk Orders","pages":[{"title":"Validate Bulk Upload","openapi":"versions/latest.json POST /orders/bulk/validate","href":"/v2/api-reference/orders/validate-bulk-upload"},{"title":"Create Bulk Upload","openapi":"versions/latest.json POST /orders/bulk","href":"/v2/api-reference/orders/create-bulk-upload"},{"title":"List Bulk Uploads","openapi":"versions/latest.json GET /orders/bulk","href":"/v2/api-reference/orders/list-bulk-uploads"},{"title":"Get Bulk Upload","openapi":"versions/latest.json GET /orders/bulk/{batch_id}","href":"/v2/api-reference/orders/get-bulk-upload"},{"title":"Download Bulk Results","openapi":"versions/latest.json GET /orders/bulk/{batch_id}/results.csv","href":"/v2/api-reference/orders/download-bulk-results"}]},{"group":"Managed Accounts","pages":[{"title":"List Managed Accounts","openapi":"versions/latest.json GET /managed-accounts","href":"/v2/api-reference/managed-accounts/list-managed-accounts"},{"title":"Create Managed Account","openapi":"versions/latest.json POST /managed-accounts","href":"/v2/api-reference/managed-accounts/create-managed-account"},{"title":"Update Managed Account","openapi":"versions/latest.json PUT /managed-accounts/{short_id}","href":"/v2/api-reference/managed-accounts/update-managed-account"},{"title":"Delete Managed Account","openapi":"versions/latest.json DELETE /managed-accounts/{short_id}","href":"/v2/api-reference/managed-accounts/delete-managed-account"},{"title":"Retailer Credentials","sidebarTitle":"Configuration","icon":"key-skeleton","href":"/v2/api-reference/configuration/managed-accounts"}]},{"group":"Returns","pages":[{"title":"Create Return Request","openapi":"versions/latest.json POST /returns","href":"/v2/api-reference/returns/create-return"},{"title":"List Return Requests","openapi":"versions/latest.json GET /returns","href":"/v2/api-reference/returns/list-returns"},{"title":"Get Return Request","openapi":"versions/latest.json GET /returns/{return_request_id}","href":"/v2/api-reference/returns/get-return"}]},{"group":"Cases","pages":[{"title":"Create Case","openapi":"versions/latest.json POST /cases","href":"/v2/api-reference/cases/create-case"},{"title":"List Cases","openapi":"versions/latest.json GET /cases","href":"/v2/api-reference/cases/list-cases"},{"title":"Get Case","openapi":"versions/latest.json GET /cases/{case_id}","href":"/v2/api-reference/cases/get-case"},{"title":"Post Case Message","openapi":"versions/latest.json POST /cases/{case_id}/messages","href":"/v2/api-reference/cases/post-case-message"},{"title":"Close Case","openapi":"versions/latest.json POST /cases/{case_id}/close","href":"/v2/api-reference/cases/close-case"}]},{"group":"Product Data","pages":[{"title":"Search Products","openapi":"versions/latest.json GET /products/search","href":"/v2/api-reference/products/search"},{"title":"Get Product Details","openapi":"versions/latest.json GET /products/{product_id}","href":"/v2/api-reference/products/get-product"},{"title":"Get Product Offers","openapi":"versions/latest.json GET /products/{product_id}/offers","href":"/v2/api-reference/products/get-product-offers"},{"title":"Get Wishlist","openapi":"versions/latest.json GET /products/wishlists","href":"/v2/api-reference/products/get-wishlist"}]},{"group":"Retailers","pages":[{"title":"List Retailers","openapi":"versions/latest.json GET /retailers","href":"/v2/api-reference/retailers/list-retailers"},{"title":"Check a Retailer","openapi":"versions/latest.json GET /retailers/check","href":"/v2/api-reference/retailers/check-retailer"}]},{"group":"Agent","pages":[{"title":"Create Agent Order","openapi":"versions/latest.json POST /agent/orders","href":"/v2/api-reference/agent/create-order"},{"title":"Agent Search","openapi":"versions/latest.json POST /agent/search","href":"/v2/api-reference/agent/search"},{"title":"Agent Product Search","openapi":"versions/latest.json POST /agent/products/search","href":"/v2/api-reference/agent/product-search"},{"title":"Agent Product Offers","openapi":"versions/latest.json POST /agent/products/offers","href":"/v2/api-reference/agent/product-offers"},{"title":"Agent Product Details","openapi":"versions/latest.json POST /agent/products/details","href":"/v2/api-reference/agent/product-details"}]},{"group":"Wallet","pages":[{"title":"Get Wallet","openapi":"versions/latest.json GET /wallet/me","href":"/v2/api-reference/wallet/get-wallet"}]},{"group":"Webhooks","pages":[{"title":"Get Webhook Endpoint","openapi":"versions/latest.json GET /webhooks/endpoint","href":"/v2/api-reference/webhooks/get-webhook-endpoint"},{"title":"Set Webhook Endpoint","openapi":"versions/latest.json PUT /webhooks/endpoint","href":"/v2/api-reference/webhooks/set-webhook-endpoint"},{"title":"Clear Webhook Endpoint","openapi":"versions/latest.json DELETE /webhooks/endpoint","href":"/v2/api-reference/webhooks/clear-webhook-endpoint"}]},{"group":"Usage","pages":[{"title":"Get My Usage","openapi":"versions/latest.json GET /usage","href":"/v2/api-reference/usage/get-my-usage"}]}]}]}]},"title":"Idempotency - Zinc Docs","buildId":"dpl_AUojGTPodKNPTVaxVPcxnNvkSVqo","deploymentId":"dpl_AUojGTPodKNPTVaxVPcxnNvkSVqo","dynamics":[],"chunks":[]}