{"_id":"5624a9e7c4bf501700bc5ec8","user":"54eb4fdedf7add210007b29b","category":{"_id":"5624bbb785a31117001c5403","pages":["5653264657978b1700df716a","5655bcf8dd82540d00278c26","5655bfd81a06b61900c66873","5655c7c0a66be71700968dd7","5660588e4320a80d00bec124","56618ad455e4450d00e62b89","56f1685a2a85600e00ea3dca"],"project":"54eb50e5615ffc1900305a16","version":"54eb63b859b1172100334fae","__v":7,"sync":{"url":"","isSync":false},"reference":true,"createdAt":"2015-10-19T09:45:27.364Z","from_sync":false,"order":11,"slug":"2-factor-authentication","title":"2-factor authentication"},"parentDoc":null,"project":"54eb50e5615ffc1900305a16","__v":7,"version":{"_id":"54eb63b859b1172100334fae","project":"54eb50e5615ffc1900305a16","forked_from":"54eb63a1867e1917009b711d","__v":28,"createdAt":"2015-02-23T17:30:32.501Z","releaseDate":"2015-02-23T17:30:32.501Z","categories":["54eb63b959b1172100334faf","54eb63b959b1172100334fb0","54eb63b959b1172100334fb1","54eb63b959b1172100334fb2","54ed8dd4ab373e2300f50eae","54ed99b2ab373e2300f50ede","55153a6de68daa2f00cff838","551546edbc466623002afe72","5515472ac28d6125001b8884","55154749c28d6125001b8885","555d9b4106dfec0d00d38ea7","5613e06e433e5735007c7708","5624bbb785a31117001c5403","56669e857cc81e0d00253f8e","568b8d837a42220d00498311","56a632277ef6620d00e2f18a","56d8147c3eb4dd0b00201aac","57a9ce2fac6db30e000d7efd","57a9cf4e944ea60e00dc3f74","58172386715dce0f00da4aa0","582dc59ee1b8692300c0dd03","589b19b4fec2730f0082e040","58b04a023529383900a759b5","58b92d1598157a0f004869bf","592e7685c58275000f20174f","59392839e376d4002f8a0474","59393064e376d4002f8a05a1","5947ae0d4005e2000f3a4fec","594a74df1d1de5001ab3517a","5954bc387a147f001b918915","59b8eeeb707542001076d3b6"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1"},"updates":["57fb8e81ec7b71290081a004","593e1cc0b612b1000f10f306"],"next":{"pages":[],"description":""},"createdAt":"2015-10-19T08:29:27.147Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"method":"post","results":{"codes":[{"name":"","code":"\"003026bbc133714df1834b8638bb496e-8f4b3d9a-e931-478d-a994-28a725159ab9\"","language":"json","status":200}]},"settings":"","examples":{"codes":[{"name":"","code":"POST /2fa/1/api-key HTTP/1.1\nHost: api.infobip.com\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\nContent-Type: application/json","language":"json"}]},"auth":"required","params":[],"url":"/2fa/:version/api-key"},"isReference":true,"order":18,"body":"In order to use the 2FA client side methods, you need to be authorized over API key.\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"API key documentation\",\n  \"body\": \"Learn more about API key and advanced API key options [here](/docs/api-key).\"\n}\n[/block]\nCreate a new API key for client side methods with the `permissions` group `TFA`. This will limit usage of this API key to a required set of methods for [sending and verifying PIN](/docs/send-and-verify-2fa-pin).\n\n\nCreate new API key request example:\n```\nPOST https://api.infobip.com/settings/1/accounts/{accountKey}/api-keys\n```\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"POST settings/1/accounts/_/api-keys HTTP/1.1\\nHost: api.infobip.com\\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\\nContent-Type: application/json\\nAccept: application/json\\n\\n{\\n    \\\"name\\\": \\\"My two factor authorization API key\\\",\\n    \\\"permissions\\\": [\\n      \\\"TFA\\\"\\n    ]\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nResponse:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    \\\"name\\\": \\\"My two factor authorization API key\\\",\\n    \\\"key\\\": \\\"C6DFA0B215B2CF24EF04794F718A3FC8\\\",\\n    \\\"publicApiKey\\\": \\\"7bd7d59cfe90e4d32b1d2f20d39c86df-fbaa8670-1008-ac7a-398a-3c11ac797c77\\\",\\n    \\\"accountKey\\\": \\\"EF04794F718A3FC8C6DFA0B215B2CF24\\\",\\n    \\\"permissions\\\": [\\n      \\\"TFA\\\"\\n    ],\\n    \\\"enabled\\\": true\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nIf successful, the response header HTTP status code will be `200 OK`. \n\n\nUse the created `publicApiKey` for authorization in the request header like in the following example:\n```\nAuthorization: App 003026bbc133714df1834b8628bb496e-8f4b3d9a-e921-478d-a994-28a725159ab9\n```","excerpt":"This method allows you to generate an API key for your account.","slug":"api-key-create","type":"basic","title":"Create API key for 2FA"}

Create API key for 2FA

This method allows you to generate an API key for your account.

In order to use the 2FA client side methods, you need to be authorized over API key. [block:callout] { "type": "info", "title": "API key documentation", "body": "Learn more about API key and advanced API key options [here](/docs/api-key)." } [/block] Create a new API key for client side methods with the `permissions` group `TFA`. This will limit usage of this API key to a required set of methods for [sending and verifying PIN](/docs/send-and-verify-2fa-pin). Create new API key request example: ``` POST https://api.infobip.com/settings/1/accounts/{accountKey}/api-keys ``` [block:code] { "codes": [ { "code": "POST settings/1/accounts/_/api-keys HTTP/1.1\nHost: api.infobip.com\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\nContent-Type: application/json\nAccept: application/json\n\n{\n \"name\": \"My two factor authorization API key\",\n \"permissions\": [\n \"TFA\"\n ]\n}", "language": "json" } ] } [/block] Response: [block:code] { "codes": [ { "code": "{\n \"name\": \"My two factor authorization API key\",\n \"key\": \"C6DFA0B215B2CF24EF04794F718A3FC8\",\n \"publicApiKey\": \"7bd7d59cfe90e4d32b1d2f20d39c86df-fbaa8670-1008-ac7a-398a-3c11ac797c77\",\n \"accountKey\": \"EF04794F718A3FC8C6DFA0B215B2CF24\",\n \"permissions\": [\n \"TFA\"\n ],\n \"enabled\": true\n}", "language": "json" } ] } [/block] If successful, the response header HTTP status code will be `200 OK`. Use the created `publicApiKey` for authorization in the request header like in the following example: ``` Authorization: App 003026bbc133714df1834b8628bb496e-8f4b3d9a-e921-478d-a994-28a725159ab9 ```