import Switchyard from "@switchyard/js-sdk"
export const sdk = new Medusa({
baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
debug: import.meta.env.DEV,
auth: {
type: "session",
},
})
sdk.admin.fulfillment.create({
location_id: "sloc_123",
provider_id: "my_fulfillment",
delivery_address: {
country_code: "us"
},
items: [
{
title: "Shirt",
sku: "SHIRT",
quantity: 1,
barcode: "123"
}
],
labels: [],
order: {},
order_id: "order_123"
})
.then(({ fulfillment }) => {
console.log(fulfillment)
}){
"fulfillment": {
"id": "<string>",
"location_id": "<string>",
"provider_id": "<string>",
"shipping_option_id": "<string>",
"provider": {
"id": "<string>",
"is_enabled": true
},
"delivery_address": {
"id": "<string>",
"fulfillment_id": "<string>",
"company": "<string>",
"first_name": "<string>",
"last_name": "<string>",
"address_1": "<string>",
"address_2": "<string>",
"city": "<string>",
"country_code": "<string>",
"province": "us-ca",
"postal_code": "<string>",
"phone": "<string>",
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
},
"items": [
{
"id": "<string>",
"title": "<string>",
"quantity": 123,
"sku": "<string>",
"barcode": "<string>",
"line_item_id": "<string>",
"inventory_item_id": "<string>",
"fulfillment_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
],
"labels": [
{
"id": "<string>",
"tracking_number": "<string>",
"tracking_url": "<string>",
"label_url": "<string>",
"fulfillment_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
],
"packed_at": "<string>",
"shipped_at": "<string>",
"delivered_at": "<string>",
"canceled_at": "<string>",
"data": {},
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
}Create a fulfillment for an order, return, exchange, and more.
import Switchyard from "@switchyard/js-sdk"
export const sdk = new Medusa({
baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
debug: import.meta.env.DEV,
auth: {
type: "session",
},
})
sdk.admin.fulfillment.create({
location_id: "sloc_123",
provider_id: "my_fulfillment",
delivery_address: {
country_code: "us"
},
items: [
{
title: "Shirt",
sku: "SHIRT",
quantity: 1,
barcode: "123"
}
],
labels: [],
order: {},
order_id: "order_123"
})
.then(({ fulfillment }) => {
console.log(fulfillment)
}){
"fulfillment": {
"id": "<string>",
"location_id": "<string>",
"provider_id": "<string>",
"shipping_option_id": "<string>",
"provider": {
"id": "<string>",
"is_enabled": true
},
"delivery_address": {
"id": "<string>",
"fulfillment_id": "<string>",
"company": "<string>",
"first_name": "<string>",
"last_name": "<string>",
"address_1": "<string>",
"address_2": "<string>",
"city": "<string>",
"country_code": "<string>",
"province": "us-ca",
"postal_code": "<string>",
"phone": "<string>",
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
},
"items": [
{
"id": "<string>",
"title": "<string>",
"quantity": 123,
"sku": "<string>",
"barcode": "<string>",
"line_item_id": "<string>",
"inventory_item_id": "<string>",
"fulfillment_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
],
"labels": [
{
"id": "<string>",
"tracking_number": "<string>",
"tracking_url": "<string>",
"label_url": "<string>",
"fulfillment_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
],
"packed_at": "<string>",
"shipped_at": "<string>",
"delivered_at": "<string>",
"canceled_at": "<string>",
"data": {},
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
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 fields. without prefix it will replace the entire default fields.
The filfillment's details.
The ID of the location the items are fulfilled from.
The ID of the provider handling this fulfillment.
The address to deliver the items to.
Show child attributes
The customer's first name.
The customer's last name.
The customer's phone.
The delivery address's company.
The delivery address's first line.
The delivery address's second line.
The delivery address's city.
The delivery address's country code.
The delivery address's ISO 3166-2 province code. Must be lower-case.
"us-ca"
The delivery address's postal code.
The delivery address's metadata, used to store custom key-value pairs.
The items to fulfill.
Show child attributes
The item's title.
The item's SKU.
The quantity to fulfill of the item.
The item's barcode.
The ID of the associated line item.
The ID of the inventory item associated with the underlying variant.
The ID of the order this fulfillment is created for.
The ID of the shipping option used in the order.
Any data useful for the fulfillment provider to handle the fulfillment.
The date and time the fulfillment was packed.
The date and time the fulfillment was shipped.
The date and time the fulfillment was delivered.
The date and time the fulfillment was canceled.
The fulfillment's metadata, used to store custom key-value pairs.
OK
A fulfillment's details.
The fulfillment's details.
Show child attributes
The fulfillment's ID.
The ID of the location the fulfillment's items are shipped from.
The ID of the fulfillment provider handling this fulfillment.
The ID of the shipping option this fulfillment is created for.
An address's details.
Show child attributes
The address's ID.
The ID of the fulfillment that the address belongs to.
The address's company.
The address's first name.
The address's last name.
The address's first line.
The address's second line.
The address's city.
The address's country code.
The address's lower-case ISO 3166-2 province code.
"us-ca"
The address's postal code.
The address's phone.
The address's metadata, can hold custom key-value pairs.
The date the address was created.
The date the address was updated.
The date the address was deleted.
The fulfillment's items.
Show child attributes
The item's ID.
The item's title.
The item's quantity to be fulfilled.
The item's SKU.
The item's barcode.
The ID of the order's line item to be fulfilled.
The ID of the inventory item of the underlying product variant.
The ID of the fulfillment the item belongs to.
The date the item was created.
The date the item was updated.
The date the item was deleted.
The fulfillment's shipment labels.
Show child attributes
The label's ID.
The label's tracking number.
The label's tracking URL.
The label's URL.
The ID of the fulfillment the label is associated with.
The date the label was created.
The date the label was updated.
The date the label was deleted.
The date the fulfillment was packed at.
The date the fulfillment was shipped at.
The date the fulfillment was delivered at.
The date the fulfillment was canceled at.
The fulfillment's data, useful for the third-party provider handling the fulfillment.
The fulfillment's metadata, can hold custom key-value pairs.
The date the fulfillment was created at.
The date the fulfillment was updated at.
The date the fulfillment was deleted at.