{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-js/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["code-walkthrough","step"]},"type":"markdown"},"seo":{"title":"Token Response | Finix.js Reference","description":"API reference for the Finix.js token response — the object returned on successful form submission for card and bank account payments.","siteUrl":"https://docs.finix.com/","llmstxt":{"hide":false,"sections":[{"title":"Getting Started","includeFiles":["guides/getting-started/**/*.md"],"excludeFiles":[]},{"title":"Online Payments","includeFiles":["guides/online-payments/**/*.md"],"excludeFiles":["guides/online-payments/payment-features/fsa-hsa-non-healthcare-mcc.md"]},{"title":"In-Person Payments","includeFiles":["guides/in-person-payments/**/*.md"],"excludeFiles":[]},{"title":"Subscriptions","includeFiles":["guides/subscriptions/**/*.md"],"excludeFiles":[]},{"title":"After the Payment","includeFiles":["guides/subscriptions/after-the-payment/**/*.md"],"excludeFiles":[]},{"title":"Managing Operations","includeFiles":["guides/managing-operations/**/*.md"],"excludeFiles":[]},{"title":"Platform Payments","includeFiles":["guides/platform-payments/**/*.md"],"excludeFiles":[]},{"title":"Payouts","includeFiles":["guides/payouts/**/*.md"],"excludeFiles":[]},{"title":"Developers","includeFiles":["additional-resources/developers/**/*.md"],"excludeFiles":[]},{"title":"Plugins","includeFiles":["additional-resources/plugins/**/*.md"],"excludeFiles":[]},{"title":"Industry Considerations","includeFiles":["guides/industry-considerations/**/*.md"],"excludeFiles":[]},{"title":"Regional Considerations","includeFiles":["guides/regional-considerations/**/*.md"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeWalkthrough","attributes":{"__idx":1,"filters":{},"filesets":[{"files":[{"path":"js/_filesets/token-response.js","content":[{"start":0,"condition":{"steps":["card-token"]},"children":["// Card token — accessed via response.data in the onSubmit callback:","const tokenData = response.data || {};","// tokenData shape:","// {","//   \"id\": \"TKeD6uad8xZc52Rqg1VhvSBw\",","//   \"created_at\": \"2025-06-10T00:31:53.54Z\",","//   \"updated_at\": \"2025-06-10T00:31:53.54Z\",","//   \"currency\": \"USD\",","//   \"expires_at\": \"2025-06-11T00:31:53.54Z\",","//   \"fingerprint\": \"FPRrcobjtdU98gr4sjiqYR1Qg\",","//   \"instrument_type\": \"PAYMENT_CARD\"","// }"]},"",{"start":15,"condition":{"steps":["card-token-usage"]},"children":["Finix.PaymentForm(\"payment-form\", \"sandbox\", \"APgPDQrLD52TYvqazjHJJchM\", {","  onSubmit: function (error, response) {","    if (error) {","      console.error(\"Tokenization failed:\", error);","      return;","    }","","    const tokenData = response.data || {};","    const token = tokenData.id; // e.g. \"TKeD6uad8xZc52Rqg1VhvSBw\"","","    // Send the token to your backend to create a Payment Instrument","    fetch(\"/your/backend\", {","      method: \"POST\",","      headers: { \"Content-Type\": \"application/json\" },","      body: JSON.stringify({ token: token }),","    });","  },","});"]},"",{"start":36,"condition":{"steps":["bank-token"]},"children":["// Bank token — same shape, instrument_type differs:","const tokenData = response.data || {};","// tokenData shape:","// {","//   \"id\": \"TKbFq4r8G5pN2mXvYhL9jW1c\",","//   \"created_at\": \"2025-06-10T00:31:53.54Z\",","//   \"updated_at\": \"2025-06-10T00:31:53.54Z\",","//   \"currency\": \"USD\",","//   \"expires_at\": \"2025-06-11T00:31:53.54Z\",","//   \"fingerprint\": \"FPaBC123def456ghi789\",","//   \"instrument_type\": \"BANK_ACCOUNT\"","// }"]},"",{"start":51,"condition":{"steps":["instrument-type-branch"]},"children":["Finix.PaymentForm(\"payment-form\", \"sandbox\", \"APgPDQrLD52TYvqazjHJJchM\", {","  onSubmit: function (error, response) {","    if (error) {","      console.error(\"Tokenization failed:\", error);","      return;","    }","","    const tokenData = response.data || {};","    const token = tokenData.id; // e.g. \"TKbFq4r8G5pN2mXvYhL9jW1c\"","","    // Send the token to your backend to create a Payment Instrument","    fetch(\"/your/backend\", {","      method: \"POST\",","      headers: { \"Content-Type\": \"application/json\" },","      body: JSON.stringify({ token: token }),","    });","  },","});"]},"",{"start":72,"condition":{"steps":["token-error"]},"children":["Finix.PaymentForm(\"payment-form\", \"sandbox\", \"APgPDQrLD52TYvqazjHJJchM\", {","  onSubmit: function (error, response) {","    if (error) {","      console.error(\"Tokenization failed:\", error);","      return;","    }","    // response is null when error is non-null","  },","});"]},""],"metadata":{"steps":["card-token","card-token-usage","bank-token","instrument-type-branch","token-error"]},"basename":"token-response.js","language":"javascript"}],"downloadAssociatedFiles":[]}],"steps":[{"id":"card-token","heading":"Card token shape"},{"id":"card-token-usage","heading":"Using the token"},{"id":"bank-token","heading":"Bank token shape"},{"id":"instrument-type-branch","heading":"Using the token"},{"id":"token-error","heading":"Error handling"}],"inputs":{},"toggles":{}},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"token-response","__idx":0},"children":["Token Response"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The response object passed to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["onSubmit"]}," ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/js/callbacks"},"children":["callback"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["form.submit()"]}," ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/js/form-instance"},"children":["method"]}," on successful tokenization. Access the token via ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["response.data"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Tokens expire ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["30 minutes"]}," after creation and should be used immediately to create a Payment Instrument."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"card-token","__idx":1},"children":["Card Token"]},{"$$mdtype":"Tag","name":"CodeStep","attributes":{"id":"card-token","heading":"Card token shape"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["On success, ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["response.data"]}," contains:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"id\": \"TKeD6uad8xZc52Rqg1VhvSBw\",\n  \"created_at\": \"2025-06-10T00:31:53.54Z\",\n  \"updated_at\": \"2025-06-10T00:31:53.54Z\",\n  \"currency\": \"USD\",\n  \"expires_at\": \"2025-06-11T00:31:53.54Z\",\n  \"fingerprint\": \"FPRrcobjtdU98gr4sjiqYR1Qg\",\n  \"instrument_type\": \"PAYMENT_CARD\"\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Field"},"children":["Field"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["id"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Token ID (prefixed ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TK"]},") — use this to create a Payment Instrument"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["currency"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["USD"]}," for most countries; ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CAD"]}," for Canadian bank accounts"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["expires_at"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Token expires 30 minutes after creation"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["fingerprint"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Unique fingerprint for the payment instrument (prefixed ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["FP"]},")"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["instrument_type"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PAYMENT_CARD"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["BANK_ACCOUNT"]},", or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["THIRD_PARTY_TOKEN"]}]}]}]}]}]}]},{"$$mdtype":"Tag","name":"CodeStep","attributes":{"id":"card-token-usage","heading":"Using the token"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Pass ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tokenData.id"]}," to your backend, then use it to create a Payment Instrument via the Finix API."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"bank-account-token","__idx":2},"children":["Bank Account Token"]},{"$$mdtype":"Tag","name":"CodeStep","attributes":{"id":"bank-token","heading":"Bank token shape"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Bank account tokens have the same shape as card tokens, with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["instrument_type: \"BANK_ACCOUNT\""]},"."]}]},{"$$mdtype":"Tag","name":"CodeStep","attributes":{"id":"instrument-type-branch","heading":"Using the token"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Pass ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tokenData.id"]}," to your backend, then use it to create a Payment Instrument via the Finix API."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"error-response","__idx":3},"children":["Error Response"]},{"$$mdtype":"Tag","name":"CodeStep","attributes":{"id":"token-error","heading":"Error handling"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When tokenization fails, ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["error"]}," is non-null and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["response"]}," is ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["null"]},"."]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Parameter"},"children":["Parameter"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["error"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["object"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Error details if submission failed"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["response"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["null"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Always ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["null"]}," when error is present"]}]}]}]}]}]}]}]},"headings":[{"value":"Token Response","id":"token-response","depth":1},{"value":"Card Token","id":"card-token","depth":2},{"value":"Bank Account Token","id":"bank-account-token","depth":2},{"value":"Error Response","id":"error-response","depth":2}],"frontmatter":{"seo":{"title":"Token Response | Finix.js Reference","description":"API reference for the Finix.js token response — the object returned on successful form submission for card and bank account payments."},"markdown":{"toc":{"hide":true}},"footer":{"hide":true}},"lastModified":"2026-05-08T19:38:51.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/js/token-response","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}