{"title":"Get your Affirm public API key","category":"default","creationDate":1796385374,"content":"<p>Affirm.js is Affirm's JavaScript library. To use it on your website, for example to show <a href=\"https:\/\/docs.affirm.com\/developers\/docs\/about-promotional-messaging-and-prequalification\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Affirm promotional messaging<\/a>, you need your Affirm public API key. You do not need this key to process Affirm payments with Adyen.<\/p>\n<p>You can get the key using the  <a href=\"https:\/\/docs.adyen.com\/api-explorer\/Management\/latest\/overview\" class=\" external-link no-image\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Management API<\/a>. The API returns the key for the environment that you send the request to. The test environment returns your Affirm sandbox key, and the live environment returns your live key.<\/p>\n<h2>Requirements<\/h2>\n<p>Before you begin, take into account the following requirements and preparations.<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">Requirement<\/th>\n<th style=\"text-align: left;\">Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\"><strong>Integration type<\/strong><\/td>\n<td style=\"text-align: left;\">Make sure that you have built your <a href=\"\/payment-methods\/affirm\">Affirm integration<\/a>.<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong><a href=\"\/development-resources\/api-credentials\/\">API credentials<\/a><\/strong><\/td>\n<td style=\"text-align: left;\">Your  <a href=\"https:\/\/docs.adyen.com\/api-explorer\/Management\/latest\/overview\" class=\" external-link no-image\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Management API<\/a> credential must have the following <a href=\"\/development-resources\/api-credentials\/roles\">role<\/a>:<ul><li><strong>Management API \u2014 Payment methods read<\/strong><\/li><\/ul><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>Setup steps<\/strong><\/td>\n<td style=\"text-align: left;\">Before you begin, <a href=\"\/payment-methods\/add-payment-methods\">add Affirm in your Customer Area<\/a>.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Get your Affirm public API key<\/h2>\n<p>To get your Affirm public API key:<\/p>\n<ol>\n<li>Make a GET  <a href=\"https:\/\/docs.adyen.com\/api-explorer\/Management\/latest\/get\/merchants\/(merchantId)\/paymentMethodSettings\" class=\"codeLabel  external-link no-image\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">\/merchants\/{merchantId}\/paymentMethodSettings<\/a> request with your merchant account ID in the path, and the <code>pageSize<\/code> query parameter set to <strong>100<\/strong>.<\/li>\n<li>\n<p>In the response, find the payment method with <code>type<\/code> <span translate=\"no\"><strong>affirm<\/strong><\/span>, and get the key from its <code>affirm.publicApiKey<\/code> field.<\/p>\n<p>If the response does not include Affirm, make a GET request to the URL in <code>_links.next.href<\/code> to get the next page. Repeat until you find Affirm, or until the response does not include <code>_links.next<\/code>.<\/p>\n<div data-component-wrapper=\"code-sample\">\n<code-sample :title=\"'Example response with the Affirm public API key'\" :id=\"''\" :code-data='[{\"language\":\"json\",\"tabTitle\":\"\",\"content\":\"{\\n    \\\"data\\\": [\\n        {\\n            \\\"id\\\": \\\"PM00000000000000000000001\\\",\\n            \\\"type\\\": \\\"affirm\\\",\\n            \\\"affirm\\\": {\\n                \\\"publicApiKey\\\": \\\"YOUR_AFFIRM_PUBLIC_API_KEY\\\"\\n            }\\n        }\\n    ]\\n}\"}]' :enable-copy-link-to-code-block=\"true\" :code-sample-card-size=\"'fullsize'\"><\/code-sample>\n<\/div>\n<\/li>\n<\/ol>\n<h2>See also<\/h2>\n<div class=\"see-also-links output-inline\" id=\"see-also\">\n<ul><li><a href=\"\/payment-methods\/affirm\"\n                        target=\"_self\"\n                        >\n                    Affirm\n                <\/a><\/li><li><a href=\"\/development-resources\/api-credentials\/roles\"\n                        target=\"_self\"\n                        >\n                    API credential roles\n                <\/a><\/li><li><a href=\"https:\/\/docs.affirm.com\/developers\/docs\/about-promotional-messaging-and-prequalification\"\n                        target=\"_blank\"\n                         class=\"external\">\n                    Affirm promotional messaging in the Affirm documentation\n                <\/a><\/li><\/ul><\/div>\n","url":"https:\/\/docs.adyen.com\/payment-methods\/affirm\/public-api-key","articleFields":{"description":"Get the Affirm public API key for your merchant account using the Management API.","feedback_component":true},"algolia":{"url":"https:\/\/docs.adyen.com\/payment-methods\/affirm\/public-api-key","title":"Get your Affirm public API key","content":"Affirm.js is Affirm's JavaScript library. To use it on your website, for example to show Affirm promotional messaging, you need your Affirm public API key. You do not need this key to process Affirm payments with Adyen.\nYou can get the key using the  Management API. The API returns the key for the environment that you send the request to. The test environment returns your Affirm sandbox key, and the live environment returns your live key.\nRequirements\nBefore you begin, take into account the following requirements and preparations.\n\n\n\nRequirement\nDescription\n\n\n\n\nIntegration type\nMake sure that you have built your Affirm integration.\n\n\nAPI credentials\nYour  Management API credential must have the following role:Management API \u2014 Payment methods read\n\n\nSetup steps\nBefore you begin, add Affirm in your Customer Area.\n\n\n\nGet your Affirm public API key\nTo get your Affirm public API key:\n\nMake a GET  \/merchants\/{merchantId}\/paymentMethodSettings request with your merchant account ID in the path, and the pageSize query parameter set to 100.\n\nIn the response, find the payment method with type affirm, and get the key from its affirm.publicApiKey field.\nIf the response does not include Affirm, make a GET request to the URL in _links.next.href to get the next page. Repeat until you find Affirm, or until the response does not include _links.next.\n\n\n\n\n\nSee also\n\n\n                    Affirm\n                \n                    API credential roles\n                \n                    Affirm promotional messaging in the Affirm documentation\n                \n","type":"page","locale":"en","boost":17,"hierarchy":{"lvl0":"Home","lvl1":"Payment methods","lvl2":"Affirm","lvl3":"Get your Affirm public API key"},"hierarchy_url":{"lvl0":"https:\/\/docs.adyen.com\/","lvl1":"https:\/\/docs.adyen.com\/payment-methods","lvl2":"https:\/\/docs.adyen.com\/payment-methods\/affirm","lvl3":"\/payment-methods\/affirm\/public-api-key"},"levels":4,"category":"Payment method","category_color":"green","tags":["Affirm","public"]}}
