import Medusa from "@medusajs/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.createShipment("ful_123", {
labels: [
{
tracking_number: "123",
tracking_url: "example.com",
label_url: "example.com"
}
]
})
.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 shipment for a fulfillment. The fulfillment must not be shipped or canceled.
import Medusa from "@medusajs/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.createShipment("ful_123", {
labels: [
{
tracking_number: "123",
tracking_url: "example.com",
label_url: "example.com"
}
]
})
.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.
The fulfillment's ID.
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.
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.