{"id":202,"date":"2019-01-21T09:47:38","date_gmt":"2019-01-21T08:47:38","guid":{"rendered":"https:\/\/developers.shoptet.cz\/?page_id=202"},"modified":"2026-03-19T16:43:32","modified_gmt":"2026-03-19T15:43:32","slug":"getting-api-access-token","status":"publish","type":"page","link":"https:\/\/developers.shoptet.com\/api\/documentation\/getting-api-access-token\/","title":{"rendered":"Getting the API access token"},"content":{"rendered":"<p>In the following section, we assume that you have already set up a partner e-shop and have been approved as a Shoptet API partner. For the purposes of this example, the partner e-shop URL will be <a href=\"https:\/\/12345.myshoptet.com\">https:\/\/12345.myshoptet.com<\/a>.<\/p>\n<h2 id=\"used-terms\">Used terms<\/h2>\n<p><strong>OAuth Access Token<\/strong><br \/>\nA <strong>unique string representing each individual installation of your add-on in an e-shop.<\/strong> It is required to obtain an API access token. It has unlimited validity and is 255 characters long.<\/p>\n<p><strong>code<\/strong><br \/>\nA string sent as a GET parameter to your specified URL (as set in the add-on settings). It has limited-time validity.<\/p>\n<p><strong>API access token<\/strong><br \/>\nA string used to access the Shoptet API. It has limited-time validity and its length ranges from 38 to 60 characters.<br \/>\nYou can obtain an API access token by making an authorized request to the OAuth server. This authorization is carried out using the OAuth access token, which you receive during the <a href=\"https:\/\/developers.shoptet.com\/api\/documentation\/installing-the-addon\/\">add-on installation process<\/a> by the e-shop.<\/p>\n<h2 id=\"how-to-obtain-an-api-access-token\">How to obtain an API access token<\/h2>\n<p><strong>This process should be independent of the installation process and must be triggered whenever you don&#8217;t have a valid API access token.<\/strong><\/p>\n<p>The API access token has a limited validity period, and each installation can have a maximum of 5 valid API access tokens per <a href=\"https:\/\/developers.shoptet.com\/api\/documentation\/eshop-verification-using-oauth\/\">OAuth access token<\/a> at any given time.<\/p>\n<p>You can obtain a new token by sending an authorized request to the OAuth server\u2019s endpoint.<\/p>\n<h3 id=\"example-of-obtaining-an-api-access-token-using-php\">Example of obtaining an API access token using PHP<\/h3>\n<pre><code class=\"lang-php\"><span class=\"hljs-comment\">\/\/ URL used to obtain an API access token. This is just an example \u2014 the actual URL can be found in:<\/span>\r\n<span class=\"hljs-comment\">\/\/ Partner e-shop administration \u2192 Connection \u2192 API partner \u2192 Access to API<\/span>\r\n$apiAccessTokenUrl = <span class=\"hljs-string\">'https:\/\/12345.myshoptet.com\/action\/ApiOAuthServer\/getAccessToken'<\/span>;\r\n\r\n<span class=\"hljs-comment\">\/\/ OAuth access token obtained during the add-on installation process.<\/span>\r\n<span class=\"hljs-comment\">\/\/ This value is unique for each e-shop installation.<\/span>\r\n$OAuthAccessToken = <span class=\"hljs-string\">'05bvguwz7zp10s6cj37csrwpfl4kfkxa6ojmophp6fabzkspi821g2yso0x4bqktwuouifak9sl6yssvpt9cwidgvt21p5czb108rlo94krwumlgal3na9ky7qdaq0jfkt180omfahbsxtoemfwstjhrf98y3b7qpytbkm53ic99ghpiqdkqb08j6gearo4kw9zeavehjvndabyoneili9qcs65tnsg9cpror28i725394tkf4rxxp62cq46xd9'<\/span>\r\n\r\n<span class=\"hljs-comment\">\/\/ The OAuth access token must be included in the Authorization header of the request.<\/span>\r\n$curl = curl_init($apiAccessTokenUrl);\r\ncurl_setopt($curl, CURLOPT_HTTPHEADER, [<span class=\"hljs-string\">'Authorization: Bearer '<\/span> . $OAuthAccessToken]);\r\ncurl_setopt($curl, CURLOPT_RETURNTRANSFER, <span class=\"hljs-keyword\">TRUE<\/span>);\r\n$response = curl_exec($curl);\r\ncurl_close($curl);\r\n<\/code><\/pre>\n<p>The <code>$response<\/code> contains the <code>access_token<\/code>, which is the API access token used to access the Shoptet API.<\/p>\n<p>An example response might look as follows:<\/p>\n<pre><code class=\"lang-json\">{<span class=\"hljs-attr\">\"access_token\"<\/span>:<span class=\"hljs-string\">\"123456-a-fltqc2nn5zg8y5h69jx8976ltwi2p1qg\"<\/span>,<span class=\"hljs-attr\">\"expires_in\"<\/span>:<span class=\"hljs-number\">1800<\/span>}\r\n<\/code><\/pre>\n<p>Next, decode the response to retrieve the <code>access_token<\/code>:<\/p>\n<pre><code class=\"lang-php\">$response = json_decode($response, <span class=\"hljs-literal\">TRUE<\/span>)<span class=\"hljs-comment\">;<\/span>\r\n$apiAccessToken = $response[<span class=\"hljs-string\">'access_token'<\/span>]<span class=\"hljs-comment\">;<\/span>\r\n<\/code><\/pre>\n<p><strong>You will use the obtained API access token to call Shoptet API endpoints<\/strong>. For instructions on how to create requests and for a full list of available endpoints, please refer to the <a href=\"https:\/\/api.docs.shoptet.com\/shoptet-api\/openapi\">documentation<\/a>.<\/p>\n<p><strong>We recommend saving the token\u2019s expiration time along with the token itself<\/strong>, so you can check its validity before making a request. If the token has expired, you should request a new API access token.<br \/>\nAlternatively, you can handle the <code>invalid token<\/code> error message returned by the API and repeat the request after obtaining a new token. Once the token has expired, the API will return a <code>401 Unauthorized<\/code> status code.<\/p>\n<p>Example of expired or invalid token response:<\/p>\n<pre><code class=\"lang-php\">{\r\n    <span class=\"hljs-attr\">\"data\"<\/span>: <span class=\"hljs-literal\">null<\/span>,\r\n    <span class=\"hljs-attr\">\"errors\"<\/span>: [{\r\n        <span class=\"hljs-attr\">\"errorCode\"<\/span>: <span class=\"hljs-string\">\"invalid-token\"<\/span>,\r\n        <span class=\"hljs-attr\">\"message\"<\/span>: <span class=\"hljs-string\">\"Invalid access token 123456-a-fltqc2nn5zg8y5h69jx8976ltwi2p1qg.\"<\/span>,\r\n        <span class=\"hljs-attr\">\"instance\"<\/span>: <span class=\"hljs-string\">\"access-token\"<\/span>\r\n    }],\r\n<\/code><\/pre>\n<pre class=\"notranslate\"><code class=\"notranslate\"><code class=\"lang-php\">   <span class=\"hljs-attr\">\"metadata\"<\/span>: {\r\n        <span class=\"hljs-attr\">\"requestId\": \"019c8c34-64f3-7328-af43-bf1e34fa39d7\"<\/span>\r\n    }<\/code><\/code><\/pre>\n<pre><code class=\"lang-php\">} <\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>For security reasons, temporary tokens, valid for 30 minutes, are used for API calls. You must request a new one before the first call and after it expires.<\/p>\n","protected":false},"author":7,"featured_media":0,"parent":230,"menu_order":4,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-202","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Getting the API access token - Shoptet Developers<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/developers.shoptet.com\/api\/documentation\/getting-api-access-token\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Getting the API access token - Shoptet Developers\" \/>\n<meta property=\"og:description\" content=\"For security reasons, temporary tokens, valid for 30 minutes, are used for API calls. You must request a new one before the first call and after it expires.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/developers.shoptet.com\/api\/documentation\/getting-api-access-token\/\" \/>\n<meta property=\"og:site_name\" content=\"Shoptet Developers\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/shoptet\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-19T15:43:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/developers.shoptet.com\/wp-content\/uploads\/2026\/02\/1200x630_en.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@Shoptet\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/developers.shoptet.com\/api\/documentation\/getting-api-access-token\/\",\"url\":\"https:\/\/developers.shoptet.com\/api\/documentation\/getting-api-access-token\/\",\"name\":\"Getting the API access token - Shoptet Developers\",\"isPartOf\":{\"@id\":\"https:\/\/developers.shoptet.com\/#website\"},\"datePublished\":\"2019-01-21T08:47:38+00:00\",\"dateModified\":\"2026-03-19T15:43:32+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/developers.shoptet.com\/api\/documentation\/getting-api-access-token\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/developers.shoptet.com\/api\/documentation\/getting-api-access-token\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/developers.shoptet.com\/api\/documentation\/getting-api-access-token\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/developers.shoptet.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Addons\",\"item\":\"https:\/\/developers.shoptet.com\/addons\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Documentation\",\"item\":\"https:\/\/developers.shoptet.com\/api\/documentation\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Getting the API access token\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/developers.shoptet.com\/#website\",\"url\":\"https:\/\/developers.shoptet.com\/\",\"name\":\"Shoptet Developers\",\"description\":\"Offer your service to [projectCount] e-shops driven by\u00a0Shoptet\",\"publisher\":{\"@id\":\"https:\/\/developers.shoptet.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/developers.shoptet.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/developers.shoptet.com\/#organization\",\"name\":\"Shoptet s.r.o.\",\"url\":\"https:\/\/developers.shoptet.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/developers.shoptet.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/developers.shoptet.com\/wp-content\/uploads\/2019\/10\/Sni\u0301mek-obrazovky-2019-10-29-v-15.17.38.png\",\"contentUrl\":\"https:\/\/developers.shoptet.com\/wp-content\/uploads\/2019\/10\/Sni\u0301mek-obrazovky-2019-10-29-v-15.17.38.png\",\"width\":486,\"height\":174,\"caption\":\"Shoptet s.r.o.\"},\"image\":{\"@id\":\"https:\/\/developers.shoptet.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/shoptet\",\"https:\/\/x.com\/Shoptet\",\"https:\/\/www.instagram.com\/shoptet.cz\/\",\"https:\/\/cz.linkedin.com\/company\/shoptet\",\"https:\/\/www.youtube.com\/channel\/UCrmFOFsJ7Nd3viUS_Kf5jsg\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Getting the API access token - Shoptet Developers","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/developers.shoptet.com\/api\/documentation\/getting-api-access-token\/","og_locale":"en_US","og_type":"article","og_title":"Getting the API access token - Shoptet Developers","og_description":"For security reasons, temporary tokens, valid for 30 minutes, are used for API calls. You must request a new one before the first call and after it expires.","og_url":"https:\/\/developers.shoptet.com\/api\/documentation\/getting-api-access-token\/","og_site_name":"Shoptet Developers","article_publisher":"https:\/\/www.facebook.com\/shoptet","article_modified_time":"2026-03-19T15:43:32+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/developers.shoptet.com\/wp-content\/uploads\/2026\/02\/1200x630_en.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_site":"@Shoptet","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/developers.shoptet.com\/api\/documentation\/getting-api-access-token\/","url":"https:\/\/developers.shoptet.com\/api\/documentation\/getting-api-access-token\/","name":"Getting the API access token - Shoptet Developers","isPartOf":{"@id":"https:\/\/developers.shoptet.com\/#website"},"datePublished":"2019-01-21T08:47:38+00:00","dateModified":"2026-03-19T15:43:32+00:00","breadcrumb":{"@id":"https:\/\/developers.shoptet.com\/api\/documentation\/getting-api-access-token\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/developers.shoptet.com\/api\/documentation\/getting-api-access-token\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/developers.shoptet.com\/api\/documentation\/getting-api-access-token\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/developers.shoptet.com\/"},{"@type":"ListItem","position":2,"name":"Addons","item":"https:\/\/developers.shoptet.com\/addons\/"},{"@type":"ListItem","position":3,"name":"Documentation","item":"https:\/\/developers.shoptet.com\/api\/documentation\/"},{"@type":"ListItem","position":4,"name":"Getting the API access token"}]},{"@type":"WebSite","@id":"https:\/\/developers.shoptet.com\/#website","url":"https:\/\/developers.shoptet.com\/","name":"Shoptet Developers","description":"Offer your service to [projectCount] e-shops driven by\u00a0Shoptet","publisher":{"@id":"https:\/\/developers.shoptet.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/developers.shoptet.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/developers.shoptet.com\/#organization","name":"Shoptet s.r.o.","url":"https:\/\/developers.shoptet.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/developers.shoptet.com\/#\/schema\/logo\/image\/","url":"https:\/\/developers.shoptet.com\/wp-content\/uploads\/2019\/10\/Sni\u0301mek-obrazovky-2019-10-29-v-15.17.38.png","contentUrl":"https:\/\/developers.shoptet.com\/wp-content\/uploads\/2019\/10\/Sni\u0301mek-obrazovky-2019-10-29-v-15.17.38.png","width":486,"height":174,"caption":"Shoptet s.r.o."},"image":{"@id":"https:\/\/developers.shoptet.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/shoptet","https:\/\/x.com\/Shoptet","https:\/\/www.instagram.com\/shoptet.cz\/","https:\/\/cz.linkedin.com\/company\/shoptet","https:\/\/www.youtube.com\/channel\/UCrmFOFsJ7Nd3viUS_Kf5jsg"]}]}},"_links":{"self":[{"href":"https:\/\/developers.shoptet.com\/wp-json\/wp\/v2\/pages\/202","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developers.shoptet.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/developers.shoptet.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/developers.shoptet.com\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/developers.shoptet.com\/wp-json\/wp\/v2\/comments?post=202"}],"version-history":[{"count":22,"href":"https:\/\/developers.shoptet.com\/wp-json\/wp\/v2\/pages\/202\/revisions"}],"predecessor-version":[{"id":4862,"href":"https:\/\/developers.shoptet.com\/wp-json\/wp\/v2\/pages\/202\/revisions\/4862"}],"up":[{"embeddable":true,"href":"https:\/\/developers.shoptet.com\/wp-json\/wp\/v2\/pages\/230"}],"wp:attachment":[{"href":"https:\/\/developers.shoptet.com\/wp-json\/wp\/v2\/media?parent=202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}