Merge branch 'master' into develop

This commit is contained in:
olivermrbl
2022-09-06 09:44:11 +02:00
966 changed files with 61268 additions and 30599 deletions
@@ -15,3 +15,18 @@ export default (fn: handler): RequestHandler => {
return fn(req, res).catch(next)
}
}
/**
* @schema multiple_errors
* title: "Multiple Errors"
* x-resourceId: multiple_errors
* properties:
* errors:
* type: array
* description: Array of errors
* items:
* $ref: "#/components/schemas/error"
* message:
* type: string
* default: "Provided request body contains errors. Please check the data and retry the request"
*/
@@ -67,3 +67,19 @@ export default () => {
res.status(statusCode).json(errObj)
}
}
/**
* @schema error
* title: "Response Error"
* x-resourceId: error
* properties:
* code:
* type: string
* description: A slug code to indicate the type of the error.
* message:
* type: string
* description: Description of the error that occurred.
* type:
* type: string
* description: A slug indicating the type of the error.
*/
@@ -27,6 +27,21 @@ import { validator } from "../../../../utils/validator"
* code:
* type: string
* description: The code for the generated token.
* x-codeSamples:
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/apps/authorizations' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "application_name": "example",
* "state": "ready",
* "code": "token"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - App
* responses:
@@ -38,6 +53,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* apps:
* $ref: "#/components/schemas/OAuth"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const validated = await validator(AdminPostAppsReq, req.body)
@@ -6,6 +6,15 @@ import { OauthService } from "../../../../services"
* summary: "List applications"
* description: "Retrieve a list of applications."
* x-authenticated: true
* x-codeSamples:
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/apps' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - App
* responses:
@@ -19,6 +28,18 @@ import { OauthService } from "../../../../services"
* type: array
* items:
* $ref: "#/components/schemas/OAuth"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const oauthService: OauthService = req.scope.resolve("oauthService")
@@ -32,6 +32,27 @@ import { validator } from "../../../../utils/validator"
* type: string
* description: The User's password.
* format: password
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* medusa.admin.auth.createSession({
* email: 'user@example.com',
* password: 'supersecret'
* }).then((({ user }) => {
* console.log(user.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/auth' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "email": "user@example.com",
* "password": "supersecret"
* }'
* tags:
* - Auth
* responses:
@@ -43,8 +64,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* user:
* $ref: "#/components/schemas/user"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* description: The user doesn't exist or the credentials are incorrect.
* $ref: "#/components/responses/incorrect_credentials"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { projectConfig: { jwt_secret } } = req.scope.resolve('configModule')
@@ -4,11 +4,39 @@
* summary: "Delete Session"
* x-authenticated: true
* description: "Deletes the current session for the logged in user."
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.auth.deleteSession()
* - lang: Shell
* label: cURL
* source: |
* curl --location --request DELETE 'https://medusa-url.com/admin/auth' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Auth
* responses:
* "200":
* description: OK
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
req.session.destroy()
@@ -7,6 +7,25 @@ import _ from "lodash"
* summary: "Get Session"
* x-authenticated: true
* description: "Gets the currently logged in User."
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.auth.getSession()
* .then(({ user }) => {
* console.log(user.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/auth' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Auth
* responses:
@@ -19,7 +38,17 @@ import _ from "lodash"
* user:
* $ref: "#/components/schemas/user"
* "400":
* description: An error occurred.
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
try {
@@ -9,6 +9,25 @@ import { EntityManager } from "typeorm"
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the batch job.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.batchJobs.cancel(batch_job_id)
* .then(({ batch_job }) => {
* console.log(batch_job.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/batch-jobs/{id}/cancel' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Batch Job
* responses:
@@ -20,6 +39,18 @@ import { EntityManager } from "typeorm"
* properties:
* batch_job:
* $ref: "#/components/schemas/batch_job"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
let batch_job = req.batch_job
@@ -9,6 +9,25 @@ import { EntityManager } from "typeorm"
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the batch job.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.batchJobs.confirm(batch_job_id)
* .then(({ batch_job }) => {
* console.log(batch_job.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/batch-jobs/{id}/confirm' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Batch Job
* responses:
@@ -20,6 +39,18 @@ import { EntityManager } from "typeorm"
* properties:
* batch_job:
* $ref: "#/components/schemas/batch_job"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
let batch_job = req.batch_job
@@ -46,6 +46,33 @@ import { validator } from "../../../../utils/validator"
* type: boolean
* description: Set a batch job in dry_run mode to get some information on what will be done without applying any modifications.
* default: false
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.batchJobs.create({
* type: 'product-export',
* context: {},
* dry_run: false
* }).then((({ batch_job }) => {
* console.log(batch_job.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/batch-jobs' \
* --header 'Content-Type: application/json' \
* --header 'Authorization: Bearer {api_token}' \
* --data-raw '{
* "type": "product-export",
* "context": { }
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Batch Job
* responses:
@@ -57,6 +84,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* batch_job:
* $ref: "#/components/schemas/batch_job"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const validated = await validator(AdminPostBatchesReq, req.body)
@@ -6,6 +6,25 @@
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the Batch Job
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.batchJobs.retrieve(batch_job_id)
* .then(({ batch_job }) => {
* console.log(batch_job.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/batch-jobs/{id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Batch Job
* responses:
@@ -17,6 +36,18 @@
* properties:
* batch_job:
* $ref: "#/components/schemas/batch_job"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const batch_job = req.batch_job
@@ -210,6 +210,25 @@ import { isDefined } from "../../../../utils"
* type: string
* description: filter by dates greater than or equal to this date
* format: date
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.batchJobs.list()
* .then(({ batch_jobs, limit, offset, count }) => {
* console.log(batch_jobs.length);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/batch-jobs' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Batch Job
* responses:
@@ -232,6 +251,18 @@ import { isDefined } from "../../../../utils"
* limit:
* type: integer
* description: The number of items per page
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req: Request, res) => {
const batchService: BatchJobService = req.scope.resolve("batchJobService")
@@ -25,6 +25,21 @@ import ProductCollectionService from "../../../../services/product-collection"
* items:
* description: "The ID of a Product to add to the Product Collection."
* type: string
* x-codeSamples:
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/collections/{id}/products/batch' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "product_ids": [
* "prod_01G1G5V2MBA328390B5AXJ610F"
* ]
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Collection
* responses:
@@ -36,6 +51,18 @@ import ProductCollectionService from "../../../../services/product-collection"
* properties:
* collection:
* $ref: "#/components/schemas/product_collection"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req: Request, res: Response) => {
const { id } = req.params
@@ -25,6 +25,31 @@ import { EntityManager } from "typeorm"
* metadata:
* description: An optional set of key-value pairs to hold additional information.
* type: object
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.collections.create({
* title: 'New Collection'
* })
* .then(({ collection }) => {
* console.log(collection.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/collections' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "title": "New Collection"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Collection
* responses:
@@ -36,6 +61,18 @@ import { EntityManager } from "typeorm"
* properties:
* collection:
* $ref: "#/components/schemas/product_collection"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req: Request, res: Response) => {
const { validatedBody } = req as { validatedBody: AdminPostCollectionsReq }
@@ -11,6 +11,25 @@ import ProductCollectionService from "../../../../services/product-collection"
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the Collection.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.collections.delete(collection_id)
* .then(({ id, object, deleted }) => {
* console.log(id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request DELETE 'https://medusa-url.com/admin/collections/{id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Collection
* responses:
@@ -31,6 +50,18 @@ import ProductCollectionService from "../../../../services/product-collection"
* type: boolean
* description: Whether the collection was deleted successfully or not.
* default: true
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req: Request, res: Response) => {
const { id } = req.params
@@ -10,6 +10,25 @@ import { defaultAdminCollectionsRelations } from "."
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the Product Collection
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.collections.retrieve(collection_id)
* .then(({ collection }) => {
* console.log(collection.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/collections/{id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Collection
* responses:
@@ -21,6 +40,18 @@ import { defaultAdminCollectionsRelations } from "."
* properties:
* collection:
* $ref: "#/components/schemas/product_collection"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req: Request, res: Response) => {
const { id } = req.params
@@ -84,6 +84,25 @@ import { Type } from "class-transformer"
* type: string
* description: filter by dates greater than or equal to this date
* format: date
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.collections.list()
* .then(({ collections, limit, offset, count }) => {
* console.log(collections.length);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/collections' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Collection
* responses:
@@ -106,6 +125,18 @@ import { Type } from "class-transformer"
* limit:
* type: integer
* description: The number of items per page
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req: Request, res: Response) => {
const productCollectionService: ProductCollectionService = req.scope.resolve(
@@ -25,6 +25,21 @@ import ProductCollectionService from "../../../../services/product-collection"
* items:
* description: "The ID of a Product to add to the Product Collection."
* type: string
* x-codeSamples:
* - lang: Shell
* label: cURL
* source: |
* curl --location --request DELETE 'https://medusa-url.com/admin/collections/{id}/products/batch' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "product_ids": [
* "prod_01G1G5V2MBA328390B5AXJ610F"
* ]
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Collection
* responses:
@@ -47,6 +62,18 @@ import ProductCollectionService from "../../../../services/product-collection"
* items:
* description: "The ID of a Product to add to the Product Collection."
* type: string
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req: Request, res: Response) => {
const { id } = req.params
@@ -25,6 +25,31 @@ import ProductCollectionService from "../../../../services/product-collection"
* metadata:
* description: An optional set of key-value pairs to hold additional information.
* type: object
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.collections.update(collection_id, {
* title: 'New Collection'
* })
* .then(({ collection }) => {
* console.log(collection.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/collections/{id}' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "title": "New Collection"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Collection
* responses:
@@ -36,6 +61,18 @@ import ProductCollectionService from "../../../../services/product-collection"
* properties:
* collection:
* $ref: "#/components/schemas/product_collection"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req: Request, res: Response) => {
const { id } = req.params
@@ -32,6 +32,39 @@ import { validator } from "../../../../utils/validator"
* id:
* description: ID of the customer
* type: string
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.customerGroups.addCustomers(customer_group_id, {
* customer_ids: [
* {
* id: customer_id
* }
* ]
* })
* .then(({ customer_group }) => {
* console.log(customer_group.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/customer-groups/{id}/customers/batch' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "customer_ids": [
* {
* "id": "cus_01G2Q4BS9GAHDBMDEN4ZQZCJB2"
* }
* ]
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Customer Group
* responses:
@@ -43,6 +76,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* customer_group:
* $ref: "#/components/schemas/customer_group"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req: Request, res: Response) => {
@@ -14,6 +14,31 @@ import { validator } from "../../../../utils/validator"
* parameters:
* - (body) name=* {string} Name of the customer group
* - (body) metadata {object} Metadata for the customer.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.customerGroups.create({
* name: 'VIP'
* })
* .then(({ customer_group }) => {
* console.log(customer_group.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/customer-groups' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "name": "VIP"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Customer Group
* responses:
@@ -25,6 +50,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* customer_group:
* $ref: "#/components/schemas/customer_group"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req: Request, res: Response) => {
@@ -11,6 +11,25 @@ import { EntityManager } from "typeorm"
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the Customer Group
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.customerGroups.delete(customer_group_id)
* .then(({ id, object, deleted }) => {
* console.log(id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request DELETE 'https://medusa-url.com/admin/customer-groups/{id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Customer Group
* responses:
@@ -31,6 +50,18 @@ import { EntityManager } from "typeorm"
* type: boolean
* description: Whether the customer group was deleted successfully or not.
* default: true
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req: Request, res: Response) => {
@@ -32,6 +32,39 @@ import { validator } from "../../../../utils/validator"
* id:
* description: ID of the customer
* type: string
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.customerGroups.removeCustomers(customer_group_id, {
* customer_ids: [
* {
* id: customer_id
* }
* ]
* })
* .then(({ customer_group }) => {
* console.log(customer_group.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request DELETE 'https://medusa-url.com/admin/customer-groups/{id}/customers/batch' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "customer_ids": [
* {
* "id": "cus_01G2Q4BS9GAHDBMDEN4ZQZCJB2"
* }
* ]
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Customer Group
* responses:
@@ -43,6 +76,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* customer_group:
* $ref: "#/components/schemas/customer_group"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req: Request, res: Response) => {
@@ -10,6 +10,25 @@ import CustomerController from "../../../../controllers/customers"
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the customer group.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.customerGroups.listCustomers(customer_group_id)
* .then(({ customers }) => {
* console.log(customers.length);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/customer-groups/{id}/customers' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Customer Group
* responses:
@@ -32,6 +51,18 @@ import CustomerController from "../../../../controllers/customers"
* limit:
* type: integer
* description: The number of items per page
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req: Request, res: Response) => {
const { id } = req.params
@@ -13,6 +13,25 @@ import { FindParams } from "../../../../types/common"
* - (path) id=* {string} The ID of the Customer Group.
* - (query) expand {string} (Comma separated) Which fields should be expanded in the customer group.
* - (query) fields {string} (Comma separated) Which fields should be included in the customer group.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.customerGroups.retrieve(customer_group_id)
* .then(({ customer_group }) => {
* console.log(customer_group.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/customer-groups/{id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Customer Group
* responses:
@@ -24,6 +43,18 @@ import { FindParams } from "../../../../types/common"
* properties:
* customer_group:
* $ref: "#/components/schemas/customer_group"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req: Request, res: Response) => {
const { id } = req.params
@@ -99,7 +99,25 @@ import { Type } from "class-transformer"
* format: date
* - (query) limit=10 {integer} Limit the number of customer groups returned.
* - (query) expand {string} (Comma separated) Which fields should be expanded in each customer groups of the result.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.customerGroups.list()
* .then(({ customer_groups, limit, offset, count }) => {
* console.log(customer_groups.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/customer-groups' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Customer Group
* responses:
@@ -122,6 +140,18 @@ import { Type } from "class-transformer"
* limit:
* type: integer
* description: The number of items per page
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req: Request, res: Response) => {
const customerGroupService: CustomerGroupService = req.scope.resolve(
@@ -26,6 +26,31 @@ import { validator } from "../../../../utils/validator"
* metadata:
* description: "Metadata for the customer."
* type: object
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.customerGroups.update(customer_group_id, {
* name: 'VIP'
* })
* .then(({ customer_group }) => {
* console.log(customer_group.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/customer-groups/{id}' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "name": "VIP"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Customer Group
* responses:
@@ -37,6 +62,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* customer_group:
* $ref: "#/components/schemas/customer_group"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req: Request, res: Response) => {
@@ -42,6 +42,37 @@ import { EntityManager } from "typeorm"
* type: object
* tags:
* - Customer
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.customers.create({
* email: 'user@example.com',
* first_name: 'Caterina',
* last_name: 'Yost',
* password: 'supersecret'
* })
* .then(({ customer }) => {
* console.log(customer.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/customers' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "email": "user@example.com",
* "first_name": "Caterina",
* "last_name": "Yost",
* "password": "supersecret"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* responses:
* 201:
* description: OK
@@ -51,6 +82,18 @@ import { EntityManager } from "typeorm"
* properties:
* customer:
* $ref: "#/components/schemas/customer"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const validated = await validator(AdminPostCustomersReq, req.body)
@@ -13,6 +13,25 @@ import { validator } from "../../../../utils/validator"
* - (path) id=* {string} The ID of the Customer.
* - (query) expand {string} (Comma separated) Which fields should be expanded in the customer.
* - (query) fields {string} (Comma separated) Which fields should be included in the customer.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.customers.retrieve(customer_id)
* .then(({ customer }) => {
* console.log(customer.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/customers/{id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Customer
* responses:
@@ -24,6 +43,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* customer:
* $ref: "#/components/schemas/customer"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -16,6 +16,25 @@ import customerController from "../../../../controllers/customers"
* - (query) expand {string} (Comma separated) Which fields should be expanded in each customer.
* - (query) q {string} a search term to search email, first_name, and last_name.
* - (query) groups[] {string} group IDs to search customers by.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.customers.list()
* .then(({ customers, limit, offset, count }) => {
* console.log(customers.length);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/customers' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Customer
* responses:
@@ -38,6 +57,18 @@ import customerController from "../../../../controllers/customers"
* limit:
* type: integer
* description: The number of items per page
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const result = await customerController.listAndCount(
@@ -60,6 +60,31 @@ import { validator } from "../../../../utils/validator"
* metadata:
* description: An optional set of key-value pairs to hold additional information.
* type: object
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.customers.update(customer_id, {
* first_name: 'Dolly'
* })
* .then(({ customer }) => {
* console.log(customer.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/customers/{id}' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "first_name": "Dolly"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Customer
* responses:
@@ -71,6 +96,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* customer:
* $ref: "#/components/schemas/customer"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -13,6 +13,25 @@ import { EntityManager } from "typeorm"
* parameters:
* - (path) id=* {string} The ID of the Discount.
* - (path) region_id=* {string} The ID of the Region.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.discounts.addRegion(discount_id, region_id)
* .then(({ discount }) => {
* console.log(discount.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/discounts/{id}/regions/{region_id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Discount
* responses:
@@ -24,6 +43,18 @@ import { EntityManager } from "typeorm"
* properties:
* discount:
* $ref: "#/components/schemas/discount"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { discount_id, region_id } = req.params
@@ -55,7 +55,32 @@ import { validator } from "../../../../utils/validator"
* description: list of customer group IDs if the condition is applied on customer groups.
* items:
* type: string
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* import { DiscountConditionOperator } from "@medusajs/medusa"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.discounts.createCondition(discount_id, {
* operator: DiscountConditionOperator.IN
* })
* .then(({ discount }) => {
* console.log(discount.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/discounts/{id}/conditions' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "operator": "in"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Discount Condition
* responses:
@@ -67,6 +92,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* discount:
* $ref: "#/components/schemas/discount"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { discount_id } = req.params
@@ -139,6 +139,44 @@ import { validator } from "../../../../utils/validator"
* metadata:
* description: An optional set of key-value pairs to hold additional information.
* type: object
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* import { AllocationType, DiscountRuleType } from "@medusajs/medusa"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.discounts.create({
* code: 'TEST',
* rule: {
* type: DiscountRuleType.FIXED,
* value: 10,
* allocation: AllocationType.ITEM
* },
* is_dynamic: false,
* is_disabled: false
* })
* .then(({ discount }) => {
* console.log(discount.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/discounts' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "code": "TEST",
* "rule": {
* "type": "fixed",
* "value": 10,
* "allocation": "item"
* }
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Discount
* responses:
@@ -150,6 +188,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* discount:
* $ref: "#/components/schemas/discount"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
@@ -22,6 +22,32 @@ import { validator } from "../../../../utils/validator"
* - (body) code=* {string} The unique code that will be used to redeem the Discount.
* - (body) usage_limit=1 {number} amount of times the discount can be applied.
* - (body) metadata {object} An optional set of key-value paris to hold additional information.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.discounts.createDynamicCode(discount_id, {
* code: 'TEST',
* usage_limit: 1
* })
* .then(({ discount }) => {
* console.log(discount.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/discounts/{id}/dynamic-codes' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "code": "TEST"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Discount
* responses:
@@ -33,6 +59,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* discount:
* $ref: "#/components/schemas/discount"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { discount_id } = req.params
@@ -20,6 +20,25 @@ import { validator } from "../../../../utils/validator"
* - (path) condition_id=* {string} The ID of the DiscountCondition
* - (query) expand {string} Comma separated list of relations to include in the results.
* - (query) fields {string} Comma separated list of fields to include in the results.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.discounts.deleteCondition(discount_id, condition_id)
* .then(({ id, object, deleted }) => {
* console.log(id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request DELETE 'https://medusa-url.com/admin/discounts/{id}/conditions/{condition_id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Discount Condition
* responses:
@@ -43,6 +62,18 @@ import { validator } from "../../../../utils/validator"
* discount:
* description: The Discount to which the condition used to belong
* $ref: "#/components/schemas/discount"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { discount_id, condition_id } = req.params
@@ -9,6 +9,25 @@ import { EntityManager } from "typeorm"
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the Discount
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.discounts.delete(discount_id)
* .then(({ id, object, deleted }) => {
* console.log(id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request DELETE 'https://medusa-url.com/admin/discounts/{id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Discount
* responses:
@@ -29,6 +48,18 @@ import { EntityManager } from "typeorm"
* type: boolean
* description: Whether the discount was deleted successfully or not.
* default: true
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { discount_id } = req.params
@@ -12,6 +12,25 @@ import { EntityManager } from "typeorm"
* parameters:
* - (path) id=* {string} The ID of the Discount
* - (path) code=* {string} The ID of the Discount
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.discounts.deleteDynamicCode(discount_id, code)
* .then(({ discount }) => {
* console.log(discount.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request DELETE 'https://medusa-url.com/admin/discounts/{id}/dynamic-codes/{code}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Discount
* responses:
@@ -23,6 +42,18 @@ import { EntityManager } from "typeorm"
* properties:
* discount:
* $ref: "#/components/schemas/discount"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { discount_id, code } = req.params
@@ -15,14 +15,32 @@ import { validator } from "../../../../utils/validator"
* @oas [get] /discounts/{discount_id}/conditions/{condition_id}
* operationId: "GetDiscountsDiscountConditionsCondition"
* summary: "Gets a DiscountCondition"
* description: "Gets a DiscountCondition"
* x-authenticated: true
* parameters:
* - (path) discount_id=* {string} The ID of the Discount.
* - (path) condition_id=* {string} The ID of the DiscountCondition.
* - (query) expand {string} Comma separated list of relations to include in the results.
* - (query) fields {string} Comma separated list of fields to include in the results.
* description: "Gets a DiscountCondition"
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.discounts.getCondition(discount_id, condition_id)
* .then(({ discount_condition }) => {
* console.log(discount_condition.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/discounts/{id}/conditions/{condition_id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Discount Condition
* responses:
@@ -34,6 +52,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* discount_condition:
* $ref: "#/components/schemas/discount_condition"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
@@ -15,6 +15,25 @@ import { validator } from "../../../../utils/validator"
* - (path) code=* {string} The code of the Discount
* - (query) expand {string} Comma separated list of relations to include in the results.
* - (query) fields {string} Comma separated list of fields to include in the results.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.discounts.retrieveByCode(code)
* .then(({ discount }) => {
* console.log(discount.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/discounts/code/{code}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Discount
* responses:
@@ -26,6 +45,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* discount:
* $ref: "#/components/schemas/discount"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { code } = req.params
@@ -15,6 +15,25 @@ import { validator } from "../../../../utils/validator"
* - (path) id=* {string} The ID of the Discount
* - (query) expand {string} Comma separated list of relations to include in the results.
* - (query) fields {string} Comma separated list of fields to include in the results.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.discounts.retrieve(discount_id)
* .then(({ discount }) => {
* console.log(discount.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/discounts/{id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Discount
* responses:
@@ -26,6 +45,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* discount:
* $ref: "#/components/schemas/discount"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { discount_id } = req.params
@@ -43,6 +43,25 @@ import { isDefined } from "../../../../utils"
* - (query) limit=20 {number} The number of items in the response
* - (query) offset=0 {number} The offset of items in response
* - (query) expand {string} Comma separated list of relations to include in the results.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.discounts.list()
* .then(({ discounts, limit, offset, count }) => {
* console.log(discounts.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/discounts' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Discount
* responses:
@@ -65,6 +84,18 @@ import { isDefined } from "../../../../utils"
* limit:
* type: integer
* description: The number of items per page
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const validated = await validator(AdminGetDiscountsParams, req.query)
@@ -12,6 +12,25 @@ import { EntityManager } from "typeorm"
* parameters:
* - (path) id=* {string} The ID of the Discount.
* - (path) region_id=* {string} The ID of the Region.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.discounts.removeRegion(discount_id, region_id)
* .then(({ discount }) => {
* console.log(discount.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request DELETE 'https://medusa-url.com/admin/discounts/{id}/regions/{region_id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Discount
* responses:
@@ -23,6 +42,18 @@ import { EntityManager } from "typeorm"
* properties:
* discount:
* $ref: "#/components/schemas/discount"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { discount_id, region_id } = req.params
@@ -50,6 +50,35 @@ import { validator } from "../../../../utils/validator"
* description: list of customer group IDs if the condition is applied on customer groups.
* items:
* type: string
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.discounts.updateCondition(discount_id, condition_id, {
* products: [
* product_id
* ]
* })
* .then(({ discount }) => {
* console.log(discount.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/discounts/{id}/conditions/{condition}' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "products": [
* "prod_01G1G5V2MBA328390B5AXJ610F"
* ]
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Discount
* responses:
@@ -61,6 +90,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* discount:
* $ref: "#/components/schemas/discount"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
@@ -127,6 +127,31 @@ import { validator } from "../../../../utils/validator"
* metadata:
* description: An object containing metadata of the discount
* type: object
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.discounts.update(discount_id, {
* code: 'TEST'
* })
* .then(({ discount }) => {
* console.log(discount.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/discounts/{id}' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "code": "TEST"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Discount
* responses:
@@ -138,6 +163,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* discount:
* $ref: "#/components/schemas/discount"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { discount_id } = req.params
@@ -116,6 +116,53 @@ import { validator } from "../../../../utils/validator"
* metadata:
* description: The optional key-value map with additional details about the Draft Order.
* type: object
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.draftOrders.create({
* email: 'user@example.com',
* region_id,
* items: [
* {
* quantity: 1
* }
* ],
* shipping_methods: [
* {
* option_id
* }
* ],
* })
* .then(({ draft_order }) => {
* console.log(draft_order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/draft-orders' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "email": "user@example.com",
* "region_id": "{region_id}"
* "items": [
* {
* "quantity": 1
* }
* ],
* "shipping_methods": [
* {
* "option_id": "{option_id}"
* }
* ]
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Draft Order
* responses:
@@ -127,6 +174,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* draft_order:
* $ref: "#/components/schemas/draft-order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
@@ -52,6 +52,31 @@ import { validator } from "../../../../utils/validator"
* metadata:
* description: The optional key-value map with additional details about the Line Item.
* type: object
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.draftOrders.addLineItem(draft_order_id, {
* quantity: 1
* })
* .then(({ draft_order }) => {
* console.log(draft_order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/draft-orders/{id}/line-items' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "quantity": 1
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Draft Order
* responses:
@@ -63,6 +88,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* draft_order:
* $ref: "#/components/schemas/draft-order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
@@ -8,6 +8,25 @@ import { EntityManager } from "typeorm"
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the Draft Order.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.draftOrders.delete(draft_order_id)
* .then(({ id, object, deleted }) => {
* console.log(id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request DELETE 'https://medusa-url.com/admin/draft-orders/{id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Draft Order
* responses:
@@ -28,6 +47,18 @@ import { EntityManager } from "typeorm"
* type: boolean
* description: Whether the draft order was deleted successfully or not.
* default: true
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -18,6 +18,25 @@ import { MedusaError } from "medusa-core-utils"
* parameters:
* - (path) id=* {string} The ID of the Draft Order.
* - (path) line_id=* {string} The ID of the Draft Order.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.draftOrders.removeLineItem(draft_order_id, item_id)
* .then(({ draft_order }) => {
* console.log(draft_order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request DELETE 'https://medusa-url.com/admin/draft-orders/{id}/line-items/{line_id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Draft Order
* responses:
@@ -29,6 +48,18 @@ import { MedusaError } from "medusa-core-utils"
* properties:
* draft_order:
* $ref: "#/components/schemas/draft-order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
@@ -16,6 +16,25 @@ import { DraftOrder } from "../../../.."
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the Draft Order.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.draftOrders.retrieve(draft_order_id)
* .then(({ draft_order }) => {
* console.log(draft_order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/draft-orders/{id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Draft Order
* responses:
@@ -27,6 +46,18 @@ import { DraftOrder } from "../../../.."
* properties:
* draft_order:
* $ref: "#/components/schemas/draft-order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
@@ -21,6 +21,25 @@ import { validator } from "../../../../utils/validator"
* - (query) offset=0 {number} The number of items to skip before the results.
* - (query) limit=50 {number} Limit the number of items returned.
* - (query) q {string} a search term to search emails in carts associated with draft orders and display IDs of draft orders
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.draftOrders.list()
* .then(({ draft_orders, limit, offset, count }) => {
* console.log(draft_orders.length);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/draft-orders' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Draft Order
* responses:
@@ -43,6 +62,18 @@ import { validator } from "../../../../utils/validator"
* limit:
* type: integer
* description: The number of items per page
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
@@ -19,6 +19,25 @@ import { EntityManager } from "typeorm"
* x-authenticated: true
* parameters:
* - (path) id=* {String} The Draft Order id.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.draftOrders.markPaid(draft_order_id)
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/draft-orders/{id}/pay' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Draft Order
* responses:
@@ -30,6 +49,18 @@ import { EntityManager } from "typeorm"
* properties:
* order:
* $ref: "#/components/schemas/draft-order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
@@ -68,6 +68,31 @@ import { validator } from "../../../../utils/validator"
* customer_id:
* description: "The ID of the Customer to associate the Draft Order with."
* type: string
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.draftOrders.update(draft_order_id, {
* email: "user@example.com"
* })
* .then(({ draft_order }) => {
* console.log(draft_order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/draft-orders/{id}' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "email": "user@example.com"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Draft Order
* responses:
@@ -79,6 +104,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* draft_order:
* $ref: "#/components/schemas/draft-order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
@@ -38,6 +38,31 @@ import { validator } from "../../../../utils/validator"
* metadata:
* description: The optional key-value map with additional details about the Line Item.
* type: object
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.draftOrders.updateLineItem(draft_order_id, line_id, {
* quantity: 1
* })
* .then(({ draft_order }) => {
* console.log(draft_order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/draft-orders/{id}/line-items/{line_id}' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "quantity": 1
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Draft Order
* responses:
@@ -49,6 +74,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* draft_order:
* $ref: "#/components/schemas/draft-order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
@@ -35,6 +35,31 @@ import { EntityManager } from "typeorm"
* metadata:
* description: An optional set of key-value pairs to hold additional information.
* type: object
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.giftCards.create({
* region_id
* })
* .then(({ gift_card }) => {
* console.log(gift_card.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/gift-cards' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "region_id": "{region_id}"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Gift Card
* responses:
@@ -46,6 +71,18 @@ import { EntityManager } from "typeorm"
* properties:
* gift_card:
* $ref: "#/components/schemas/gift_card"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const validated = await validator(AdminPostGiftCardsReq, req.body)
@@ -8,6 +8,25 @@ import { EntityManager } from "typeorm"
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the Gift Card to delete.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.giftCards.delete(gift_card_id)
* .then(({ id, object, deleted }) => {
* console.log(id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request DELETE 'https://medusa-url.com/admin/gift-cards/{id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Gift Card
* responses:
@@ -28,6 +47,18 @@ import { EntityManager } from "typeorm"
* type: boolean
* description: Whether the gift card was deleted successfully or not.
* default: true
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -8,6 +8,25 @@ import { defaultAdminGiftCardFields, defaultAdminGiftCardRelations } from "./"
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the Gift Card.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.giftCards.retrieve(gift_card_id)
* .then(({ gift_card }) => {
* console.log(gift_card.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/gift-cards/{id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Gift Card
* responses:
@@ -19,6 +38,18 @@ import { defaultAdminGiftCardFields, defaultAdminGiftCardRelations } from "./"
* properties:
* gift_card:
* $ref: "#/components/schemas/gift_card"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -16,6 +16,25 @@ import { isDefined } from "../../../../utils"
* - (query) offset=0 {number} The number of items to skip before the results.
* - (query) limit=50 {number} Limit the number of items returned.
* - (query) q {string} a search term to search by code or display ID
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.giftCards.list()
* .then(({ gift_cards, limit, offset, count }) => {
* console.log(gift_cards.length);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/gift-cards' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Gift Card
* responses:
@@ -38,6 +57,18 @@ import { isDefined } from "../../../../utils"
* limit:
* type: integer
* description: The number of items per page
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const validated = await validator(AdminGetGiftCardsParams, req.query)
@@ -35,6 +35,31 @@ import { EntityManager } from "typeorm"
* metadata:
* description: An optional set of key-value pairs to hold additional information.
* type: object
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.giftCards.update(gift_card_id, {
* region_id
* })
* .then(({ gift_card }) => {
* console.log(gift_card.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/gift-cards/{id}' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "region_id": "{region_id}"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Gift Card
* responses:
@@ -46,6 +71,18 @@ import { EntityManager } from "typeorm"
* properties:
* gift_card:
* $ref: "#/components/schemas/gift_card"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -39,11 +39,61 @@ import { EntityManager } from "typeorm"
* description: The desired password for the User
* type: string
* format: password
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.invites.accept({
* token,
* user: {
* first_name: 'Brigitte',
* last_name: 'Collier',
* password: 'supersecret'
* }
* })
* .then(() => {
* // successful
* })
* .catch(() => {
* // an error occurred
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/invites/accept' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "token": "{token}",
* "user": {
* "first_name": "Brigitte",
* "last_name": "Collier",
* "password": "supersecret"
* }
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Invite
* responses:
* 200:
* description: OK
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const validated = await validator(AdminPostInvitesInviteAcceptReq, req.body)
@@ -27,11 +27,53 @@ import { EntityManager } from "typeorm"
* description: "The role of the user to be created."
* type: string
* enum: [admin, member, developer]
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.invites.create({
* user: "user@example.com",
* role: "admin"
* })
* .then(() => {
* // successful
* })
* .catch(() => {
* // an error occurred
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/invites' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "user": "user@example.com",
* "role": "admin"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Invite
* responses:
* 200:
* description: OK
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const validated = await validator(AdminPostInvitesReq, req.body)
@@ -9,6 +9,25 @@ import InviteService from "../../../../services/invite"
* x-authenticated: true
* parameters:
* - (path) invite_id=* {string} The ID of the Invite
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.invites.delete(invite_id)
* .then(({ id, object, deleted }) => {
* console.log(id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request DELETE 'https://medusa-url.com/admin/invites/{invite_id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Invite
* responses:
@@ -29,6 +48,18 @@ import InviteService from "../../../../services/invite"
* type: boolean
* description: Whether or not the Invite was deleted.
* default: true
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { invite_id } = req.params
@@ -6,6 +6,25 @@ import InviteService from "../../../../services/invite"
* summary: "Lists all Invites"
* description: "Lists all Invites"
* x-authenticated: true
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.invites.list()
* .then(({ invites }) => {
* console.log(invites.length);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/invites' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Invite
* responses:
@@ -19,6 +38,18 @@ import InviteService from "../../../../services/invite"
* type: array
* items:
* $ref: "#/components/schemas/invite"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const inviteService: InviteService = req.scope.resolve("inviteService")
@@ -9,11 +9,45 @@ import { EntityManager } from "typeorm"
* x-authenticated: true
* parameters:
* - (path) invite_id=* {string} The ID of the Invite
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.invites.resend(invite_id)
* .then(() => {
* // successful
* })
* .catch(() => {
* // an error occurred
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/invites/{invite_id}/resend' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Invite
* responses:
* 200:
* description: OK
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { invite_id } = req.params
@@ -28,6 +28,35 @@ import { EntityManager } from "typeorm"
* value:
* type: string
* description: The content of the Note to create.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.notes.create({
* resource_id,
* resource_type: 'order',
* value: 'We delivered this order'
* })
* .then(({ note }) => {
* console.log(note.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/notes' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "resource_id": "{resource_id}",
* "resource_type": "order",
* "value": "We delivered this order"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Note
* responses:
@@ -39,6 +68,18 @@ import { EntityManager } from "typeorm"
* properties:
* note:
* $ref: "#/components/schemas/note"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*
*/
export default async (req, res) => {
@@ -9,6 +9,25 @@ import NoteService from "../../../../services/note"
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the Note to delete.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.notes.delete(note_id)
* .then(({ id, object, deleted }) => {
* console.log(id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request DELETE 'https://medusa-url.com/admin/notes/{id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Note
* responses:
@@ -29,6 +48,18 @@ import NoteService from "../../../../services/note"
* type: boolean
* description: Whether or not the Note was deleted.
* default: true
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -8,6 +8,25 @@ import NoteService from "../../../../services/note"
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the note to retrieve.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.notes.retrieve(note_id)
* .then(({ note }) => {
* console.log(note.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/notes/{id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Note
* responses:
@@ -19,6 +38,18 @@ import NoteService from "../../../../services/note"
* properties:
* note:
* $ref: "#/components/schemas/note"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -15,6 +15,25 @@ import { validator } from "../../../../utils/validator"
* - (query) limit=50 {number} The number of notes to get
* - (query) offset=0 {number} The offset at which to get notes
* - (query) resource_id {string} The ID which the notes belongs to
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.notes.list()
* .then(({ notes, limit, offset, count }) => {
* console.log(notes.length);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/notes' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Note
* responses:
@@ -37,6 +56,18 @@ import { validator } from "../../../../utils/validator"
* limit:
* type: integer
* description: The number of items per page
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const validated = await validator(AdminGetNotesParams, req.query)
@@ -21,6 +21,31 @@ import { EntityManager } from "typeorm"
* value:
* type: string
* description: The updated description of the Note.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.notes.update(note_id, {
* value: 'We delivered this order'
* })
* .then(({ note }) => {
* console.log(note.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/notes/{id}' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "value": "We delivered this order"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Note
* responses:
@@ -32,7 +57,18 @@ import { EntityManager } from "typeorm"
* properties:
* note:
* $ref: "#/components/schemas/note"
*
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -27,6 +27,25 @@ import { validator } from "../../../../utils/validator"
* - (query) resource_id {string} The ID of the resource that the Notification refers to.
* - (query) to {string} The address that the Notification was sent to. This will usually be an email address, but represent other addresses such as a chat bot user id
* - (query) include_resends {string} A boolean indicating whether the result set should include resent notifications or not
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.notifications.list()
* .then(({ notifications }) => {
* console.log(notifications.length);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/notifications' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Notification
* responses:
@@ -40,6 +59,18 @@ import { validator } from "../../../../utils/validator"
* type: array
* items:
* $ref: "#/components/schemas/notification"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const notificationService: NotificationService = req.scope.resolve(
@@ -26,6 +26,25 @@ import { validator } from "../../../../utils/validator"
* to:
* description: "A new address or user identifier that the Notification should be sent to"
* type: string
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.notifications.resend(notification_id)
* .then(({ notification }) => {
* console.log(notification.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/notifications/{id}/resend' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Notification
* responses:
@@ -37,6 +56,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* notification:
* $ref: "#/components/schemas/notification"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -22,6 +22,33 @@ import { EntityManager } from "typeorm"
* - (body) price=* {integer} The price (excluding VAT) that should be charged for the Shipping Method
* - (body) option_id=* {string} The ID of the Shipping Option to create the Shipping Method from.
* - (body) data {object} The data required for the Shipping Option to create a Shipping Method. This will depend on the Fulfillment Provider.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.addShippingMethod(order_id, {
* price: 1000,
* option_id
* })
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/{id}/shipping-methods' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "price": 1000,
* "option_id": "{option_id}"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Order
* responses:
@@ -33,6 +60,18 @@ import { EntityManager } from "typeorm"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -9,6 +9,25 @@ import { EntityManager } from "typeorm"
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the Order.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.archive(order_id)
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/{id}/archive' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Order
* responses:
@@ -20,6 +39,18 @@ import { EntityManager } from "typeorm"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -13,6 +13,25 @@ import { MedusaError } from "medusa-core-utils"
* parameters:
* - (path) id=* {string} The ID of the Order.
* - (path) claim_id=* {string} The ID of the Claim.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.cancelClaim(order_id, claim_id)
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/{id}/claims/{claim_id}/cancel' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Claim
* responses:
@@ -24,6 +43,18 @@ import { MedusaError } from "medusa-core-utils"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id, claim_id } = req.params
@@ -18,6 +18,25 @@ import { MedusaError } from "medusa-core-utils"
* - (path) id=* {string} The ID of the Order which the Claim relates to.
* - (path) claim_id=* {string} The ID of the Claim which the Fulfillment relates to.
* - (path) fulfillment_id=* {string} The ID of the Fulfillment.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.cancelClaimFulfillment(order_id, claim_id, fulfillment_id)
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/{id}/claims/{claim_id}/fulfillments/{fulfillment_id}/cancel' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Fulfillment
* responses:
@@ -29,6 +48,18 @@ import { MedusaError } from "medusa-core-utils"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id, claim_id, fulfillment_id } = req.params
@@ -18,6 +18,25 @@ import { MedusaError } from "medusa-core-utils"
* - (path) id=* {string} The ID of the Order which the Swap relates to.
* - (path) swap_id=* {string} The ID of the Swap which the Fulfillment relates to.
* - (path) fulfillment_id=* {string} The ID of the Fulfillment.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.cancelSwapFulfillment(order_id, swap_id, fulfillment_id)
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/{id}/swaps/{swap_id}/fulfillments/{fulfillment_id}/cancel' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Fulfillment
* responses:
@@ -29,6 +48,18 @@ import { MedusaError } from "medusa-core-utils"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id, swap_id, fulfillment_id } = req.params
@@ -13,6 +13,25 @@ import { MedusaError } from "medusa-core-utils"
* parameters:
* - (path) id=* {string} The ID of the Order which the Fulfillment relates to.
* - (path) fulfillment_id=* {string} The ID of the Fulfillment
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.cancelFulfillment(order_id, fulfillment_id)
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/{id}/fulfillments/{fulfillment_id}/cancel' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Fulfillment
* responses:
@@ -24,6 +43,18 @@ import { MedusaError } from "medusa-core-utils"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id, fulfillment_id } = req.params
@@ -11,6 +11,25 @@ import { EntityManager } from "typeorm"
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the Order.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.cancel(order_id)
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/{id}/cancel' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Order
* responses:
@@ -22,6 +41,18 @@ import { EntityManager } from "typeorm"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -13,6 +13,25 @@ import { MedusaError } from "medusa-core-utils"
* parameters:
* - (path) id=* {string} The ID of the Order.
* - (path) swap_id=* {string} The ID of the Swap.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.cancelSwap(order_id, swap_id)
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/{order_id}/swaps/{swap_id}/cancel' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Swap
* responses:
@@ -24,6 +43,18 @@ import { MedusaError } from "medusa-core-utils"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id, swap_id } = req.params
@@ -11,6 +11,25 @@ import { EntityManager } from "typeorm"
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the Order.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.capturePayment(order_id)
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/{id}/capture' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Order
* responses:
@@ -22,6 +41,18 @@ import { EntityManager } from "typeorm"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -9,6 +9,25 @@ import { EntityManager } from "typeorm"
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the Order.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.complete(order_id)
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/{id}/complete' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Order
* responses:
@@ -20,6 +39,18 @@ import { EntityManager } from "typeorm"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -29,6 +29,31 @@ import { EntityManager } from "typeorm"
* type: array
* items:
* type: string
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.createClaimShipment(order_id, claim_id, {
* fulfillment_id
* })
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/{id}/claims/{claim_id}/shipments' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "fulfillment_id": "{fulfillment_id}"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Claim
* responses:
@@ -40,6 +65,18 @@ import { EntityManager } from "typeorm"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id, claim_id } = req.params
@@ -126,6 +126,43 @@ import { validator } from "../../../../utils/validator"
* metadata:
* description: An optional set of key-value pairs to hold additional information.
* type: object
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.createClaim(order_id, {
* type: 'refund',
* claim_items: [
* {
* item_id,
* quantity: 1
* }
* ]
* })
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/{id}/claims' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "type": "refund",
* "claim_items": [
* {
* "item_id": "asdsd",
* "quantity": 1
* }
* ]
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Claim
* responses:
@@ -137,6 +174,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
@@ -50,6 +50,41 @@ import { validator } from "../../../../utils/validator"
* metadata:
* description: An optional set of key-value pairs to hold additional information.
* type: object
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.createFulfillment(order_id, {
* items: [
* {
* item_id,
* quantity: 1
* }
* ]
* })
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/{id}/fulfillment' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "items": [
* {
* "item_id": "{item_id}",
* "quantity": 1
* }
* ]
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Fulfillment
* responses:
@@ -61,6 +96,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -38,6 +38,31 @@ import { validator } from "../../../../utils/validator"
* no_notification:
* description: If set to true no notification will be send related to this Shipment.
* type: boolean
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.createShipment(order_id, {
* fulfillment_id
* })
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/{id}/shipment' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "fulfillment_id": "{fulfillment_id}"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Order
* responses:
@@ -49,6 +74,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -38,6 +38,31 @@ import { validator } from "../../../../utils/validator"
* no_notification:
* description: If set to true no notification will be sent related to this Claim.
* type: boolean
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.createSwapShipment(order_id, swap_id, {
* fulfillment_id
* })
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/{id}/swaps/{swap_id}/shipments' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "fulfillment_id": "{fulfillment_id}"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Swap
* responses:
@@ -49,6 +74,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id, swap_id } = req.params
@@ -105,6 +105,41 @@ import { validator } from "../../../../utils/validator"
* description: If true, swaps can be completed with items out of stock
* type: boolean
* default: true
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.createSwap(order_id, {
* return_items: [
* {
* item_id,
* quantity: 1
* }
* ]
* })
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/{id}/swaps' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "return_items": [
* {
* "item_id": "asfasf",
* "quantity": 1
* }
* ]
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Swap
* responses:
@@ -116,6 +151,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -25,6 +25,25 @@ import { validator } from "../../../../utils/validator"
* no_notification:
* description: If set to true no notification will be send related to this Claim.
* type: boolean
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.fulfillClaim(order_id, claim_id)
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/{id}/claims/{claim_id}/fulfillments' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Fulfillment
* responses:
@@ -36,6 +55,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id, claim_id } = req.params
@@ -25,6 +25,25 @@ import { validator } from "../../../../utils/validator"
* no_notification:
* description: If set to true no notification will be send related to this Claim.
* type: boolean
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.fulfillSwap(order_id, swap_id)
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/{id}/swaps/{swap_id}/fulfillments' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Fulfillment
* responses:
@@ -36,6 +55,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id, swap_id } = req.params
@@ -8,6 +8,25 @@ import { OrderService } from "../../../../services"
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the Order.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.retrieve(order_id)
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/orders/{id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Order
* responses:
@@ -19,6 +38,18 @@ import { OrderService } from "../../../../services"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -153,6 +153,25 @@ import { pick } from "lodash"
* - (query) limit=50 {integer} Limit the number of orders returned.
* - (query) expand {string} (Comma separated) Which fields should be expanded in each order of the result.
* - (query) fields {string} (Comma separated) Which fields should be included in each order of the result.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.list()
* .then(({ orders, limit, offset, count }) => {
* console.log(orders.length);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/orders' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Order
* responses:
@@ -175,6 +194,18 @@ import { pick } from "lodash"
* limit:
* type: integer
* description: The number of items per page
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const orderService: OrderService = req.scope.resolve("orderService")
@@ -12,6 +12,25 @@ import { EntityManager } from "typeorm"
* parameters:
* - (path) id=* {string} The ID of the Order.
* - (path) swap_id=* {string} The ID of the Swap.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.processSwapPayment(order_id, swap_id)
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/{id}/swaps/{swap_id}/process-payment' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Swap
* responses:
@@ -23,6 +42,18 @@ import { EntityManager } from "typeorm"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id, swap_id } = req.params
@@ -39,6 +39,33 @@ import { EntityManager } from "typeorm"
* no_notification:
* description: If set to true no notification will be send related to this Refund.
* type: boolean
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.refundPayment(order_id, {
* amount: 1000,
* reason: 'Do not like it'
* })
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/adasda/refund' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "amount": 1000,
* "reason": "Do not like it"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Order
* responses:
@@ -50,6 +77,18 @@ import { EntityManager } from "typeorm"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -79,6 +79,41 @@ import { validator } from "../../../../utils/validator"
* refund:
* description: The amount to refund.
* type: integer
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.requestReturn(order_id, {
* items: [
* {
* item_id,
* quantity: 1
* }
* ]
* })
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/{id}/return' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "items": [
* {
* "item_id": "{item_id}",
* "quantity": 1
* }
* ]
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Return
* - Order
@@ -91,6 +126,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -105,6 +105,31 @@ import { EntityManager } from "typeorm"
* metadata:
* description: An optional set of key-value pairs to hold additional information.
* type: object
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.updateClaim(order_id, claim_id, {
* no_notification: true
* })
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/{id}/claims/{claim_id}' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "no_notification": true
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Claim
* responses:
@@ -116,6 +141,18 @@ import { EntityManager } from "typeorm"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id, claim_id } = req.params
@@ -90,6 +90,31 @@ import { validator } from "../../../../utils/validator"
* no_notification:
* description: A flag to indicate if no notifications should be emitted related to the updated order.
* type: boolean
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.orders.update(order_id, {
* email: 'user@example.com'
* })
* .then(({ order }) => {
* console.log(order.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/orders/adasda' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "email": "user@example.com"
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Order
* responses:
@@ -101,6 +126,18 @@ import { validator } from "../../../../utils/validator"
* properties:
* order:
* $ref: "#/components/schemas/order"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
@@ -56,6 +56,43 @@ import { EntityManager } from "typeorm"
* override:
* description: "If true the prices will replace all existing prices associated with the Price List."
* type: boolean
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.priceLists.addPrices(price_list_id, {
* prices: [
* {
* amount: 1000,
* variant_id,
* currency_code: 'eur'
* }
* ]
* })
* .then(({ price_list }) => {
* console.log(price_list.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/price-lists/{id}/prices/batch' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "prices": [
* {
* "amount": 100,
* "variant_id": "afasfa",
* "currency_code": "eur"
* }
* ]
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Price List
* responses:
@@ -67,6 +104,18 @@ import { EntityManager } from "typeorm"
* properties:
* price_list:
* $ref: "#/components/schemas/price_list"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -98,6 +98,50 @@ import { Type } from "class-transformer"
* id:
* description: The ID of a customer group
* type: string
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* import { PriceListType } from "@medusajs/medusa"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.priceLists.create({
* name: 'New Price List',
* description: 'A new price list',
* type: PriceListType.SALE,
* prices: [
* {
* amount: 1000,
* variant_id,
* currency_code: 'eur'
* }
* ]
* })
* .then(({ price_list }) => {
* console.log(price_list.id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/price-lists' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "name": "New Price List",
* "description": "A new price list",
* "type": "sale",
* "prices": [
* {
* "amount": 1000,
* "variant_id": "afafa",
* "currency_code": "eur"
* }
* ]
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Price List
* responses:
@@ -109,6 +153,18 @@ import { Type } from "class-transformer"
* properties:
* price_list:
* $ref: "#/components/schemas/price_list"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req: Request, res) => {
const priceListService: PriceListService =
@@ -9,6 +9,25 @@ import PriceListService from "../../../../services/price-list"
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the Price List to delete.
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.priceLists.delete(price_list_id)
* .then(({ id, object, deleted }) => {
* console.log(id);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request DELETE 'https://medusa-url.com/admin/price-lists/{id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Price List
* responses:
@@ -29,6 +48,18 @@ import PriceListService from "../../../../services/price-list"
* type: boolean
* description: Whether or not the items were deleted.
* default: true
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params
@@ -22,6 +22,35 @@ import { validator } from "../../../../utils/validator"
* type: array
* items:
* type: string
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.priceLists.deletePrices(price_list_id, {
* price_ids: [
* price_id
* ]
* })
* .then(({ ids, object, deleted }) => {
* console.log(ids.length);
* });
* - lang: Shell
* label: cURL
* source: |
* curl --location --request DELETE 'https://medusa-url.com/admin/price-lists/{id}/prices/batch' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "price_ids": [
* "adasfa"
* ]
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Price List
* responses:
@@ -44,6 +73,18 @@ import { validator } from "../../../../utils/validator"
* type: boolean
* description: Whether or not the items were deleted.
* default: true
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
const { id } = req.params

Some files were not shown because too many files have changed in this diff Show More