{"id":507,"date":"2024-12-28T23:23:24","date_gmt":"2024-12-28T21:23:24","guid":{"rendered":"https:\/\/hostup.se\/en\/support\/?p=507"},"modified":"2025-12-01T15:04:16","modified_gmt":"2025-12-01T13:04:16","slug":"api-autentisering","status":"publish","type":"post","link":"https:\/\/hostup.se\/en\/support\/api-autentisering\/","title":{"rendered":"API \u2013 Authentication &amp; Guidance"},"content":{"rendered":"\n<p>When authenticating against the <a href=\"https:\/\/cloud.hostup.se\/api-management\">public API<\/a>, you use an API key. You can create as many keys as you like, and we recommend creating one API key for each service you integrate with.<\/p>\n\n\n\n<p>Example command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -H \"Authorization: Bearer YOUR_API_KEY\" \\\n  https:&#47;&#47;cloud.hostup.se\/api\/hosting-accounts<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/hostup.se\/support\/wp-content\/uploads\/2024\/12\/api-nyckel-1024x472.png\" alt=\"\" class=\"wp-image-1068\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Limited_permissions\"><\/span>Limited permissions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If you only want to grant an API key permission to perform certain tasks through the API\u2014such as managing DNS records\u2014you just need to assign the scopes required for that.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/hostup.se\/support\/wp-content\/uploads\/2024\/12\/api-management-scopes-940x1024.png\" alt=\"\" class=\"wp-image-1069\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"API_documentation\"><\/span>API documentation<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can find our API documentation at <a href=\"https:\/\/cloud.hostup.se\/api-management\">https:\/\/cloud.hostup.se\/api-management<\/a>. It is currently only available once you\u2019re logged in. The documentation is somewhat limited right now, but one very useful thing to know is that our customer portal uses the exact same API that you, as a developer, have access to.<\/p>\n\n\n\n<p>That means that if you open your browser\u2019s dev console, you can see how the API is being used and which endpoints are available.<\/p>\n\n\n\n<p>A good example of this is that, when I opened the window to configure permissions, an API call was made to https:\/\/cloud.hostup.se\/api\/keys\/scopes. There I can see exactly what the page retrieves from the backend to create the layout you\u2019re seeing on the screen.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/hostup.se\/support\/wp-content\/uploads\/2024\/12\/browser-console-1024x861.png\" alt=\"\" class=\"wp-image-1070\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Example_Stop_a_VPS\"><\/span>Example: Stop a VPS<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/hostup.se\/support\/wp-content\/uploads\/2024\/12\/browser-console-stop-vps-1024x333.png\" alt=\"\" class=\"wp-image-1072\"\/><\/figure>\n\n\n\n<p>With the browser console you can figure out absolutely everything. If you try stopping your VPS in the control panel, the browser\u2019s dev console shows you exactly what\u2019s going on. In this case a POST request is sent to https:\/\/cloud.hostup.se\/api\/vm\/16793\/status with the payload <br>{action: &#8220;stop&#8221;, force: true}. Armed with this information, we can craft and test a curl request against the API directly from the terminal:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -X POST 'https:\/\/cloud.hostup.se\/api\/vm\/16793\/status' \\\n  -H 'X-API-Key: YOUR_API_KEY' \\\n  -H 'Content-Type: application\/json' \\\n  -d '{\"action\": \"stop\", force: true}'<\/code><\/pre>\n\n\n\n<p>In response, I got back:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n    \"success\": true,\n    \"timestamp\": \"2025-11-27T17:32:05.199Z\",\n    \"requestId\": \"9098d7b0-4cff-40c2-bc43-964500cbde6e\",\n    \"data\": {\n        \"success\": true,\n        \"action\": \"stop\",\n        \"jobId\": \"stop-16793-1764264725196\",\n        \"message\": \"stop operation queued\",\n        \"estimated_time\": 30\n    }\n}<\/code><\/pre>\n\n\n\n<p>This is exactly what makes things so much easier for our developers. Because our control panel uses the very same API you have access to, neither of us needs to reinvent the wheel. You also don\u2019t have to rely on poor or outdated API documentation, since you can always open the browser console to see precisely how the API works.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Example_2_Manage_automatic_SSL_renewal_via_ACHME\"><\/span>Example 2: Manage automatic SSL renewal via ACHME<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We\u2019ve created a plugin for acme.sh: <\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/hostup\/acme.sh\/blob\/9980ad0fef9634b105c59711dd5f470a4b35f080\/dnsapi\/dns_hostup.sh\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/hostup\/acme.sh\/blob\/9980ad0fef9634b105c59711dd5f470a4b35f080\/dnsapi\/dns_hostup.sh<\/a><\/p>\n\n\n\n<p>The code above gives you a few more examples of how to use our API.<\/p>\n\r\n\t\t\t<div id=\"daexthefu-container\"\r\n\t\t\t\tclass=\"daexthefu-container daexthefu-layout-side-by-side daexthefu-alignment-left\"\r\n\t\t\t\tdata-post-id=\"507\">\r\n\r\n\t\t\t\t<div class=\"daexthefu-feedback\">\r\n\t\t\t\t\t<div class=\"daexthefu-text\">\r\n\t\t\t\t\t\t<h3 class=\"daexthefu-title\">Was this article helpful?<\/h3>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<div class=\"daexthefu-buttons-container\">\r\n\t\t\t\t\t\t<div class=\"daexthefu-buttons\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t<div class=\"daexthefu-yes daexthefu-button daexthefu-button-type-icon\" data-value=\"1\">\r\n\t\t\t\t\r\n                <svg>\r\n                    <defs>\r\n                        <style>.happy-face-cls-1{fill:#c9c9c9;}.happy-face-cls-2{fill:#e1e1e1;}.happy-face-cls-3{fill:#676767;}<\/style>\r\n                    <\/defs>\r\n                    <g id=\"happy_face\">\r\n                        <circle class=\"happy-face-cls-1 daexthefu-icon-primary-color\" cx=\"24\" cy=\"24\" r=\"17\" \/>\r\n                        <path class=\"happy-face-cls-2 daexthefu-icon-circle\" d=\"m24,3c11.58,0,21,9.42,21,21s-9.42,21-21,21S3,35.58,3,24,12.42,3,24,3m0-1C11.85,2,2,11.85,2,24s9.85,22,22,22,22-9.85,22-22S36.15,2,24,2h0Z\" \/>\r\n                        <circle class=\"happy-face-cls-3 daexthefu-icon-secondary-color\" cx=\"18\" cy=\"22\" r=\"2\" \/>\r\n                        <circle class=\"happy-face-cls-3 daexthefu-icon-secondary-color\" cx=\"30\" cy=\"22\" r=\"2\" \/>\r\n                        <path class=\"happy-face-cls-3 daexthefu-icon-secondary-color\" d=\"m16.79,29c-1.19,0-1.89,1.31-1.25,2.32,1.77,2.81,4.9,4.68,8.47,4.68s6.7-1.87,8.47-4.68c.63-1.01-.06-2.32-1.25-2.32-3.67,0-10.76,0-14.43,0Z\" \/>\r\n                    <\/g>\r\n                <\/svg>\t\t\t<\/div>\r\n\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t<div class=\"daexthefu-no daexthefu-button daexthefu-button-type-icon\" data-value=\"0\">\r\n\t\t\t\t\r\n                <svg>\r\n                    <defs>\r\n                        <style>\r\n                            .sad-face-cls-1{fill:#c9c9c9;}.sad-face-cls-2{fill:#676767;}.sad-face-cls-3{fill:#e1e1e1;}.sad-face-cls-4{fill:#676767;}\r\n                        <\/style>\r\n                    <\/defs>\r\n                    <g id=\"sad_face\">\r\n                        <circle class=\"sad-face-cls-1 daexthefu-icon-primary-color\" cx=\"24\" cy=\"24\" r=\"17\" \/>\r\n                        <path class=\"sad-face-cls-3 daexthefu-icon-circle\" d=\"m24,3c11.58,0,21,9.42,21,21s-9.42,21-21,21S3,35.58,3,24,12.42,3,24,3m0-1C11.85,2,2,11.85,2,24s9.85,22,22,22,22-9.85,22-22S36.15,2,24,2h0Z\" \/>\r\n                        <circle class=\"sad-face-cls-4 daexthefu-icon-secondary-color\" cx=\"18\" cy=\"22\" r=\"2\" \/>\r\n                        <circle class=\"sad-face-cls-4 daexthefu-icon-secondary-color\" cx=\"30\" cy=\"22\" r=\"2\" \/>\r\n                        <path class=\"sad-face-cls-2 daexthefu-icon-secondary-color\" d=\"M16.9,34.5c-0.4,0-0.8-0.1-1.1-0.4c-0.6-0.6-0.6-1.5,0-2.1c2.2-2.2,5.1-3.4,8.1-3.4c3.1,0,6,1.2,8.1,3.4\r\n                        c0.6,0.6,0.6,1.5,0,2.1s-1.5,0.6-2.1,0c-1.6-1.6-3.7-2.5-6-2.5s-4.4,0.9-6,2.5C17.7,34.4,17.3,34.5,16.9,34.5z\" \/>\r\n                    <\/g>\r\n                <\/svg>\t\t\t<\/div>\r\n\r\n\t\t\t\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t<\/div>\r\n\r\n\t\t\t\t<div class=\"daexthefu-comment\">\r\n\t\t\t\t\t<div class=\"daexthefu-comment-top-container\">\r\n\t\t\t\t\t\t<label id=\"daexthefu-comment-label\" class=\"daexthefu-comment-label\"><\/label>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"daexthefu-comment-character-counter-container\">\r\n\t\t\t\t\t\t\t\t<div id=\"daexthefu-comment-character-counter-number\"\r\n\t\t\t\t\t\t\t\t\tclass=\"daexthefu-comment-character-counter-number\"><\/div>\r\n\t\t\t\t\t\t\t\t<div class=\"daexthefu-comment-character-counter-text\"><\/div>\r\n\t\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<textarea id=\"daexthefu-comment-textarea\" class=\"daexthefu-comment-textarea\"\r\n\t\t\t\t\t\t\t\tplaceholder=\"Skriv ditt meddelande\"\r\n\t\t\t\t\t\t\t\tmaxlength=\"\r\n\t\t\t\t\t\t\t\t400\t\t\t\t\t\t\t\t\t\"><\/textarea>\r\n\t\t\t\t\t<div class=\"daexthefu-comment-buttons-container\">\r\n\t\t\t\t\t\t<button class=\"daexthefu-comment-submit daexthefu-button\">Skicka in<\/button>\r\n\t\t\t\t\t\t<button class=\"daexthefu-comment-cancel daexthefu-button\">Avbryt<\/button>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t<\/div>\r\n\r\n\t\t\t\t<div class=\"daexthefu-successful-submission-text\">Tack f\u00f6r din feedback!<\/div>\r\n\r\n\t\t\t<\/div>\r\n\r\n\t\t\t","protected":false},"excerpt":{"rendered":"<p>When authenticating against the public API, you use an API key. You can create as many keys as you like, and we recommend creating one API key for each service you integrate with. Example command: Limited permissions If you only want to grant an API key permission to perform certain tasks through the API\u2014such as [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_helpful_status":1,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-507","post","type-post","status-publish","format-standard","hentry","category-kundzon"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/hostup.se\/en\/support\/wp-json\/wp\/v2\/posts\/507","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hostup.se\/en\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hostup.se\/en\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hostup.se\/en\/support\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hostup.se\/en\/support\/wp-json\/wp\/v2\/comments?post=507"}],"version-history":[{"count":4,"href":"https:\/\/hostup.se\/en\/support\/wp-json\/wp\/v2\/posts\/507\/revisions"}],"predecessor-version":[{"id":633,"href":"https:\/\/hostup.se\/en\/support\/wp-json\/wp\/v2\/posts\/507\/revisions\/633"}],"wp:attachment":[{"href":"https:\/\/hostup.se\/en\/support\/wp-json\/wp\/v2\/media?parent=507"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hostup.se\/en\/support\/wp-json\/wp\/v2\/categories?post=507"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hostup.se\/en\/support\/wp-json\/wp\/v2\/tags?post=507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}