1"use strict";(self.webpackChunkuthana_api_docs=self.webpackChunkuthana_api_docs||[]).push([["7708"],{7473(e,n,a){a.r(n),a.d(n,{metadata:()=>t,default:()=>d,frontMatter:()=>c,contentTitle:()=>o,toc:()=>u,assets:()=>h});var t=JSON.parse('{"id":"intro","title":"API key","description":"Your API key authenticates requests to the Uthana API. Keep it private and rotate it if you suspect it has been compromised.","source":"@site/docs/intro.mdx","sourceDirName":".","slug":"/api-key","permalink":"/docs/api/api-key","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":1,"frontMatter":{"id":"intro","title":"API key","slug":"/api-key","sidebar_position":1},"sidebar":"docs","previous":{"title":"Quickstart","permalink":"/docs/api/"},"next":{"title":"Locomotion","permalink":"/docs/api/capabilities/locomotion"}}'),i=a(4848),s=a(8453),r=a(7331),l=a(7250);let c={id:"intro",title:"API key",slug:"/api-key",sidebar_position:1},o="API key",h={},u=[{value:"Get your API key",id:"get-your-api-key",level:2},{value:"Use your API key",id:"use-your-api-key",level:2},{value:"Custom domain",id:"custom-domain",level:3},{value:"Security tips",id:"security-tips",level:2}];function p(e){let n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",ul:"ul",...(0,s.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"api-key",children:"API key"})}),"\n",(0,i.jsx)(n.p,{children:"Your API key authenticates requests to the Uthana API. Keep it private and rotate it if you suspect it has been compromised."}),"\n",(0,i.jsx)(n.h2,{id:"get-your-api-key",children:"Get your API key"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["Create an account at ",(0,i.jsx)(n.a,{href:"https://uthana.com",children:"uthana.com"}),"."]}),"\n",(0,i.jsxs)(n.li,{children:["Choose an API-enabled plan on the ",(0,i.jsx)(n.a,{href:"https://uthana.com/pricing",children:"pricing page"}),"."]}),"\n",(0,i.jsxs)(n.li,{children:["Open your account settings at ",(0,i.jsx)(n.a,{href:"https://uthana.com/app/account",children:"uthana.com/app/account"}),"."]}),"\n",(0,i.jsx)(n.li,{children:"Generate a new API key."}),"\n",(0,i.jsxs)(n.li,{children:["(Optional) paste it into the ",(0,i.jsx)(n.code,{children:"API key"})," field (in the top-right corner of the page) to use it with the Uthana API docs (desktop version only)."]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"use-your-api-key",children:"Use your API key"}),"\n",(0,i.jsx)(n.p,{children:"The official Python and JavaScript/TypeScript clients handle authentication for you. Pass your key when constructing the client. For other languages, use HTTP Basic auth with your API key as the username and an empty password."}),"\n",(0,i.jsxs)(r.A,{groupId:"language",children:[(0,i.jsx)(l.A,{value:"curl",label:"Shell",children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:'API_KEY="{{apiKey}}"\n\ncurl "https://uthana.com/graphql" \\\n -u $API_KEY: \\\n -H "Content-Type: application/json" \\\n -d \'{"query": "{ __typename }"}\'\n'})})}),(0,i.jsxs)(l.A,{value:"python",label:"Python",children:[(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'import asyncio\nfrom uthana import Uthana\n\nclient = Uthana("{{apiKey}}")\n\nasync def main():\n user = await client.org.get_user()\n print(user.get("name"), user.get("email"))\n\nasyncio.run(main())\n'})}),(0,i.jsxs)(n.p,{children:["Install: ",(0,i.jsx)(n.code,{children:"pip install uthana"})," \xb7 ",(0,i.jsx)(n.a,{href:"https://github.com/Uthana/uthana-python-client",children:"Python client docs"})]})]}),(0,i.jsxs)(l.A,{value:"typescript",label:"TypeScript",children:[(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-typescript",children:'import { UthanaClient } from "@uthana/client";\n\nconst client = new UthanaClient("{{apiKey}}");\n\n// Confirm the key is valid\nconst user = await client.org.getUser();\nconsole.log(user.name, user.email);\n'})}),(0,i.jsxs)(n.p,{children:["Install: ",(0,i.jsx)(n.code,{children:"npm install @uthana/client"})," \xb7 ",(0,i.jsx)(n.a,{href:"https://github.com/Uthana/uthana-js-client",children:"JS/TS client docs"})]})]}),(0,i.jsxs)(l.A,{value:"react",label:"React",children:[(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-tsx",children:'import { UthanaProvider, useUthanaUser } from "@uthana/react";\n\n// Wrap your app once \u2014 all hooks work inside the provider\nfunction App() {\n return (\n <UthanaProvider apiKey="{{apiKey}}">\n <UserInfo />\n </UthanaProvider>\n );\n}\n\nfunction UserInfo() {\n const { user } = useUthanaUser();\n return <p>{user ? `Authenticated as ${user.name}` : "Loading..."}</p>;\n}\n'})}),(0,i.jsxs)(n.p,{children:["Install: ",(0,i.jsx)(n.code,{children:"npm install @uthana/react @uthana/client @tanstack/react-query"})," \xb7 ",(0,i.jsx)(n.a,{href:"https://github.com/Uthana/uthana-js-client",children:"JS/TS client docs"})]})]}),(0,i.jsx)(l.A,{value:"csharp",label:"C#",children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-csharp",children:'var request = new\n{\n query = "{ __typename }"\n};\n\nvar json = JsonSerializer.Serialize(request);\nvar content = new StringContent(json, Encoding.UTF8, "application/json");\n\nvar authValue = Convert.ToBase64String(Encoding.UTF8.GetBytes("{{apiKey}}:"));\n_httpClient.DefaultRequestHeaders.Authorization =\n new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", authValue);\n\nvar response = await _httpClient.PostAsync("https://uthana.com/graphql", content);\nresponse.EnsureSuccessStatusCode();\n'})})})]}),"\n",(0,i.jsx)(n.h3,{id:"custom-domain",children:"Custom domain"}),"\n",(0,i.jsxs)(n.p,{children:["If you use a non-default API host, pass the ",(0,i.jsx)(n.code,{children:"domain"})," option:"]}),"\n",(0,i.jsxs)(r.A,{groupId:"language",children:[(0,i.jsx)(l.A,{value:"curl",label:"Shell",children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:'# Replace uthana.com with your custom domain in all request URLs\ncurl "https://custom.uthana.example/graphql" \\\n -u $API_KEY: \\\n -H "Content-Type: application/json" \\\n -d \'{"query": "{ __typename }"}\'\n'})})}),(0,i.jsx)(l.A,{value:"python",label:"Python",children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'client = Uthana("{{apiKey}}", domain="custom.uthana.example")\n'})})}),(0,i.jsx)(l.A,{value:"typescript",label:"TypeScript",children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-typescript",children:'const client = new UthanaClient("{{apiKey}}", { domain: "custom.uthana.example" });\n'})})}),(0,i.jsx)(l.A,{value:"react",label:"React",children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-tsx",children:'<UthanaProvider apiKey="{{apiKey}}" domain="custom.uthana.example">\n <App />\n</UthanaProvider>\n'})})}),(0,i.jsx)(l.A,{value:"csharp",label:"C#",children:(0,i.jsxs)(n.p,{children:["Replace ",(0,i.jsx)(n.code,{children:"uthana.com"})," with your custom domain in all request URLs."]})})]}),"\n",(0,i.jsx)(n.h2,{id:"security-tips",children:"Security tips"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"Treat your API key like a password."}),"\n",(0,i.jsx)(n.li,{children:"Store it in a secret manager or environment variable, not in source code."}),"\n",(0,i.jsx)(n.li,{children:"Rotate the key if it appears in logs or shared code."}),"\n"]})]})}function d(e={}){let{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(p,{...e})}):p(e)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.