1 /**
2 * @oas [post] /admin/api-keys
3 * operationId: PostApiKeys
4 * summary: Create Api Key
5 * description: |
6 * Create a secret or publishable API key.
7 * A secret API key is used for admin authentication.
8 *
9 * A publishable API key is used by client applications to set the scope of the request.
10 * x-authenticated: true
11 * security:
12 * - api_token: []
13 * - cookie_auth: []
14 * - jwt_token: []
15 * requestBody:
16 * content:
17 * application/json:
18 * schema:
19 * $ref: "#/components/schemas/AdminCreateApiKey"
20 * x-codeSamples:
21 * - lang: JavaScript
22 * label: JS SDK
23 * source: |-
24 * import Medusa from "@medusajs/js-sdk"
25 *
26 * export const sdk = new Medusa({
27 * baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
28 * debug: import.meta.env.DEV,
29 * auth: {
30 * type: "session",
31 * },
32 * })
33 *
34 * sdk.admin.apiKey.create({
35 * title: "Development",
36 * type: "publishable"
37 * })
38 * .then(({ api_key }) => {
39 * console.log(api_key)
40 * })
41 * - lang: Shell
42 * label: cURL
43 * source: |-
44 * curl -X POST '{backend_url}/admin/api-keys' \
45 * -H 'Authorization: Bearer {jwt_token}' \
46 * -H 'Content-Type: application/json' \
47 * --data-raw '{
48 * "title": "{value}",
49 * "type": "{value}"
50 * }'
51 * tags:
52 * - Api Keys
53 * responses:
54 * "200":
55 * description: OK
56 * content:
57 * application/json:
58 * schema:
59 * $ref: "#/components/schemas/AdminApiKeyResponse"
60 * "400":
61 * $ref: "#/components/responses/400_error"
62 * "401":
63 * $ref: "#/components/responses/unauthorized"
64 * "404":
65 * $ref: "#/components/responses/not_found_error"
66 * "409":
67 * $ref: "#/components/responses/invalid_state_error"
68 * "422":
69 * $ref: "#/components/responses/invalid_request_error"
70 * "500":
71 * $ref: "#/components/responses/500_error"
72 * x-workflow: createApiKeysWorkflow
73 * x-events: []
74 *
75 */
76