1 /**
2 * @oas [post] /admin/fulfillments
3 * operationId: PostFulfillments
4 * summary: Create Fulfillment
5 * description: Create a fulfillment for an order, return, exchange, and more.
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 * $ref: "#/components/schemas/AdminCreateFulfillment"
29 * x-codeSamples:
30 * - lang: JavaScript
31 * label: JS SDK
32 * source: |-
33 * import Medusa from "@medusajs/js-sdk"
34 *
35 * export const sdk = new Medusa({
36 * baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
37 * debug: import.meta.env.DEV,
38 * auth: {
39 * type: "session",
40 * },
41 * })
42 *
43 * sdk.admin.fulfillment.create({
44 * location_id: "sloc_123",
45 * provider_id: "my_fulfillment",
46 * delivery_address: {
47 * country_code: "us"
48 * },
49 * items: [
50 * {
51 * title: "Shirt",
52 * sku: "SHIRT",
53 * quantity: 1,
54 * barcode: "123"
55 * }
56 * ],
57 * labels: [],
58 * order: {},
59 * order_id: "order_123"
60 * })
61 * .then(({ fulfillment }) => {
62 * console.log(fulfillment)
63 * })
64 * - lang: Shell
65 * label: cURL
66 * source: |-
67 * curl -X POST '{backend_url}/admin/fulfillments' \
68 * -H 'Authorization: Bearer {jwt_token}' \
69 * -H 'Content-Type: application/json' \
70 * --data-raw '{
71 * "location_id": "{value}",
72 * "provider_id": "{value}",
73 * "delivery_address": {
74 * "first_name": "{value}",
75 * "last_name": "{value}",
76 * "phone": "{value}",
77 * "company": "{value}",
78 * "address_1": "{value}",
79 * "address_2": "{value}",
80 * "city": "{value}",
81 * "country_code": "{value}",
82 * "province": "us-ca",
83 * "postal_code": "{value}",
84 * "metadata": {}
85 * },
86 * "items": [
87 * {
88 * "title": "{value}",
89 * "sku": "{value}",
90 * "quantity": 1667318922870784,
91 * "barcode": "{value}",
92 * "line_item_id": "{value}",
93 * "inventory_item_id": "{value}"
94 * }
95 * ],
96 * "labels": [
97 * {
98 * "tracking_number": "{value}",
99 * "tracking_url": "{value}",
100 * "label_url": "{value}"
101 * }
102 * ],
103 * "order": {},
104 * "order_id": "{value}",
105 * "shipping_option_id": "{value}",
106 * "data": {},
107 * "packed_at": "2024-11-12T18:37:37.122Z",
108 * "shipped_at": "2025-04-13T12:39:42.432Z",
109 * "delivered_at": "2025-01-29T19:05:57.056Z",
110 * "canceled_at": "2025-02-16T02:12:11.763Z",
111 * "metadata": {}
112 * }'
113 * tags:
114 * - Fulfillments
115 * responses:
116 * "200":
117 * description: OK
118 * content:
119 * application/json:
120 * schema:
121 * $ref: "#/components/schemas/AdminFulfillmentResponse"
122 * "400":
123 * $ref: "#/components/responses/400_error"
124 * "401":
125 * $ref: "#/components/responses/unauthorized"
126 * "404":
127 * $ref: "#/components/responses/not_found_error"
128 * "409":
129 * $ref: "#/components/responses/invalid_state_error"
130 * "422":
131 * $ref: "#/components/responses/invalid_request_error"
132 * "500":
133 * $ref: "#/components/responses/500_error"
134 * x-workflow: createFulfillmentWorkflow
135 * x-events: []
136 *
137 */
138