|
1
|
/** |
|
2
|
* @oas [post] /admin/collections |
|
3
|
* operationId: PostCollections |
|
4
|
* summary: Create Collection |
|
5
|
* description: Create a collection. |
|
6
|
* x-authenticated: true |
|
7
|
* parameters: |
|
8
|
* - name: fields |
|
9
|
* in: query |
|
10
|
* description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default |
|
11
|
* fields. without prefix it will replace the entire default fields. |
|
12
|
* required: false |
|
13
|
* schema: |
|
14
|
* type: string |
|
15
|
* title: fields |
|
16
|
* description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default |
|
17
|
* fields. without prefix it will replace the entire default fields. |
|
18
|
* externalDocs: |
|
19
|
* url: "#select-fields-and-relations" |
|
20
|
* security: |
|
21
|
* - api_token: [] |
|
22
|
* - cookie_auth: [] |
|
23
|
* - jwt_token: [] |
|
24
|
* requestBody: |
|
25
|
* content: |
|
26
|
* application/json: |
|
27
|
* schema: |
|
28
|
* allOf: |
|
29
|
* - type: object |
|
30
|
* description: The collection's details. |
|
31
|
* required: |
|
32
|
* - title |
|
33
|
* properties: |
|
34
|
* title: |
|
35
|
* type: string |
|
36
|
* title: title |
|
37
|
* description: The collection's title. |
|
38
|
* handle: |
|
39
|
* type: string |
|
40
|
* title: handle |
|
41
|
* description: The collection's handle. |
|
42
|
* metadata: |
|
43
|
* type: object |
|
44
|
* description: The collection's metadata. Can hold custom key-value pairs. |
|
45
|
* - type: object |
|
46
|
* description: The collection's details. |
|
47
|
* properties: |
|
48
|
* additional_data: |
|
49
|
* type: object |
|
50
|
* description: Pass additional custom data to the API route. This data is passed to the underlying workflow under the `additional_data` parameter. |
|
51
|
* description: the product collection's details. |
|
52
|
* x-codeSamples: |
|
53
|
* - lang: JavaScript |
|
54
|
* label: JS SDK |
|
55
|
* source: |- |
|
56
|
* import Medusa from "@medusajs/js-sdk" |
|
57
|
* |
|
58
|
* export const sdk = new Medusa({ |
|
59
|
* baseUrl: import.meta.env.VITE_BACKEND_URL || "/", |
|
60
|
* debug: import.meta.env.DEV, |
|
61
|
* auth: { |
|
62
|
* type: "session", |
|
63
|
* }, |
|
64
|
* }) |
|
65
|
* |
|
66
|
* sdk.admin.productCollection.create({ |
|
67
|
* title: "Summer Collection" |
|
68
|
* }) |
|
69
|
* .then(({ collection }) => { |
|
70
|
* console.log(collection) |
|
71
|
* }) |
|
72
|
* - lang: Shell |
|
73
|
* label: cURL |
|
74
|
* source: |- |
|
75
|
* curl -X POST '{backend_url}/admin/collections' \ |
|
76
|
* -H 'Authorization: Bearer {jwt_token}' \ |
|
77
|
* -H 'Content-Type: application/json' \ |
|
78
|
* --data-raw '{ |
|
79
|
* "title": "{value}", |
|
80
|
* "metadata": {} |
|
81
|
* }' |
|
82
|
* tags: |
|
83
|
* - Collections |
|
84
|
* responses: |
|
85
|
* "200": |
|
86
|
* description: OK |
|
87
|
* content: |
|
88
|
* application/json: |
|
89
|
* schema: |
|
90
|
* $ref: "#/components/schemas/AdminCollectionResponse" |
|
91
|
* "400": |
|
92
|
* $ref: "#/components/responses/400_error" |
|
93
|
* "401": |
|
94
|
* $ref: "#/components/responses/unauthorized" |
|
95
|
* "404": |
|
96
|
* $ref: "#/components/responses/not_found_error" |
|
97
|
* "409": |
|
98
|
* $ref: "#/components/responses/invalid_state_error" |
|
99
|
* "422": |
|
100
|
* $ref: "#/components/responses/invalid_request_error" |
|
101
|
* "500": |
|
102
|
* $ref: "#/components/responses/500_error" |
|
103
|
* x-workflow: createCollectionsWorkflow |
|
104
|
* x-events: |
|
105
|
* - name: product-collection.created |
|
106
|
* payload: |- |
|
107
|
* ```ts |
|
108
|
* { |
|
109
|
* id, // The ID of the product collection |
|
110
|
* } |
|
111
|
* ``` |
|
112
|
* description: Emitted when product collections are created. |
|
113
|
* deprecated: false |
|
114
|
* |
|
115
|
*/ |
|
116
|
|