admin

package
v0.0.0-...-993f9dd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminDeleteUploadsReq

type AdminDeleteUploadsReq struct {
	FileKey string `json:"file_key"`
}

@oas:schema:AdminDeleteUploadsReq type: object description: "The details of the file to delete." required:

  • file_key

properties:

file_key:
  description: "key of the file to delete. This is obtained when you first uploaded the file, or by the file service if you used it directly."
  type: string

type AdminGetVariantsParams

type AdminGetVariantsParams struct {
	types.FilterableProductVariant
	CartId       uuid.UUID `json:"cart_id,omitempty" validate:"omitempty"`
	RegionId     uuid.UUID `json:"region_id,omitempty" validate:"omitempty"`
	CurrencyCode string    `json:"currency_code,omitempty" validate:"omitempty"`
	CustomerId   uuid.UUID `json:"customer_id,omitempty" validate:"omitempty"`
}

type AdminPostBatchesReq

type AdminPostBatchesReq struct {
	Type    string     `json:"type"`
	Context core.JSONB `json:"context"`
	DryRun  bool       `json:"dry_run,omitempty"`
}

type AdminPostUploadsDownloadUrlReq

type AdminPostUploadsDownloadUrlReq struct {
	FileKey string `json:"file_key"`
}

@oas:schema:AdminPostUploadsDownloadUrlReq type: object description: "The details of the file to retrieve its download URL." required:

  • file_key

properties:

file_key:
  description: "key of the file to obtain the download link for. This is obtained when you first uploaded the file, or by the file service if you used it directly."
  type: string

type AnalyticsConfig

type AnalyticsConfig struct {
	// contains filtered or unexported fields
}

func NewAnalyticsConfig

func NewAnalyticsConfig(r Registry) *AnalyticsConfig

func (*AnalyticsConfig) Create

func (m *AnalyticsConfig) Create(context fiber.Ctx) error

No OAS for this route, for internal use only.

func (*AnalyticsConfig) Delete

func (m *AnalyticsConfig) Delete(context fiber.Ctx) error

No OAS for this route, for internal use only.

func (*AnalyticsConfig) Get

func (m *AnalyticsConfig) Get(context fiber.Ctx) error

No OAS for this route, for internal use only.

func (*AnalyticsConfig) SetRoutes

func (m *AnalyticsConfig) SetRoutes(router fiber.Router)

func (*AnalyticsConfig) Update

func (m *AnalyticsConfig) Update(context fiber.Ctx) error

No OAS for this route, for internal use only.

type App

type App struct {
	// contains filtered or unexported fields
}

func NewApp

func NewApp(r Registry) *App

func (*App) Authorize

func (m *App) Authorize(context fiber.Ctx) error

@oas:path [post] /admin/apps/authorizations operationId: "PostApps" summary: "Generate Token for App" description: "Use an app's Oauth provider to generate and store a new token for authentication." x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostAppsReq"

x-codegen:

method: authorize

x-codeSamples:

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/apps/authorizations' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "application_name": "example", "state": "ready", "code": "token" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Apps Oauth

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminAppsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*App) List

func (m *App) List(context fiber.Ctx) error

@oas:path [get] /admin/apps operationId: "GetApps" summary: "List Applications" description: "Retrieve a list of applications registered in the Medusa backend." x-authenticated: true x-codegen:

method: list

x-codeSamples:

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/apps' \ -H x-medusa-access-token: "{api_token}"

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Apps Oauth

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminAppsListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description:  "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*App) SetRoutes

func (m *App) SetRoutes(router fiber.Router)

type Auth

type Auth struct {
	// contains filtered or unexported fields
}

func NewAuth

func NewAuth(r Registry) *Auth

func (*Auth) CreateSession

func (m *Auth) CreateSession(context fiber.Ctx) error

@oas:path [post] /admin/auth operationId: "PostAuth" summary: "User Login" x-authenticated: false description: "Log a User in and includes the Cookie session in the response header. The cookie session can be used in subsequent requests to authorize the user to perform admin functionalities. When using Medusa's JS or Medusa React clients, the cookie is automatically attached to subsequent requests." requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostAuthReq"

x-codegen:

method: createSession

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: "[email protected]", password: "supersecret" }) .then(({ user }) => { console.log(user.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminLogin } from "medusa-react"

    const Login = () => { const adminLogin = useAdminLogin() // ...

    const handleLogin = () => { adminLogin.mutate({ email: "[email protected]", password: "supersecret", }, { onSuccess: ({ user }) => { console.log(user) } }) }

    // ... }

    export default Login

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/auth' \ -H 'Content-Type: application/json' \ --data-raw '{ "email": "[email protected]", "password": "supersecret" }'

tags:

  • Auth

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminAuthRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/incorrect_credentials"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Auth) DeleteSession

func (m *Auth) DeleteSession(context fiber.Ctx) error

@oas:path [delete] /admin/auth operationId: "DeleteAuth" summary: "User Logout" x-authenticated: true description: "Delete the current session for the logged in user. This will only work if you're using Cookie session for authentication. If the API token is still passed in the header, the user is still authorized to perform admin functionalities in other API Routes." x-codegen:

method: deleteSession

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 medusa.admin.auth.deleteSession()

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteSession } from "medusa-react"

    const Logout = () => { const adminLogout = useAdminDeleteSession() // ...

    const handleLogout = () => { adminLogout.mutate(undefined, { onSuccess: () => { // user logged out. } }) }

    // ... }

    export default Logout

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/auth' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Auth

responses:

"200":
  description: "OK"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Auth) GetSession

func (m *Auth) GetSession(context fiber.Ctx) error

@oas:path [get] /admin/auth operationId: "GetAuth" summary: "Get Current User" x-authenticated: true description: "Get the currently logged in user's details." x-codegen:

method: getSession

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: tsx label: Medusa React source: | import React from "react" import { useAdminGetSession } from "medusa-react"

    const Profile = () => { const { user, isLoading } = useAdminGetSession()

    return ( <div> {isLoading && <span>Loading...</span>} {user && <span>{user.email}</span>} </div> ) }

    export default Profile

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/auth' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Auth

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminAuthRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Auth) GetTocken

func (m *Auth) GetTocken(context fiber.Ctx) error

@oas:path [post] /admin/auth/token operationId: "PostToken" summary: "User Login (JWT)" x-authenticated: false description: "After a successful login, a JWT token is returned, which can be used to send authenticated requests." requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostAuthReq"

x-codegen:

method: getToken

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.getToken({ email: '[email protected]', password: 'supersecret' }) .then(({ access_token }) => { console.log(access_token); })
  • lang: Shell label: cURL source: | curl -X POST '{backend_url}/admin/auth/token' \ -H 'Content-Type: application/json' \ --data-raw '{ "email": "[email protected]", "password": "supersecret" }'

tags:

  • Auth

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminBearerAuthRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/incorrect_credentials"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Auth) SetRoutes

func (m *Auth) SetRoutes(router fiber.Router)

type Batch

type Batch struct {
	// contains filtered or unexported fields
}

func NewBatch

func NewBatch(r Registry) *Batch

func (*Batch) Cancel

func (m *Batch) Cancel(context fiber.Ctx) error

@oas:path [post] /admin/batch-jobs/{id}/cancel operationId: "PostBatchJobsBatchJobCancel" summary: "Cancel a Batch Job" description: "Mark a batch job as canceled. When a batch job is canceled, the processing of the batch job doesn’t automatically stop." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the batch job.

x-codegen:

method: cancel

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(batchJobId) .then(({ batch_job }) => { console.log(batch_job.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCancelBatchJob } from "medusa-react"

    type Props = { batchJobId: string }

    const BatchJob = ({ batchJobId }: Props) => { const cancelBatchJob = useAdminCancelBatchJob(batchJobId) // ...

    const handleCancel = () => { cancelBatchJob.mutate(undefined, { onSuccess: ({ batch_job }) => { console.log(batch_job) } }) }

    // ... }

    export default BatchJob

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/batch-jobs/{id}/cancel' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Batch Jobs

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminBatchJobRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Batch) Confirm

func (m *Batch) Confirm(context fiber.Ctx) error

@oas:path [post] /admin/batch-jobs/{id}/confirm operationId: "PostBatchJobsBatchJobConfirmProcessing" summary: "Confirm a Batch Job" description: "When a batch job is created, it is not executed automatically if `dry_run` is set to `true`. This API Route confirms that the batch job should be executed." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the batch job.

x-codegen:

method: confirm

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(batchJobId) .then(({ batch_job }) => { console.log(batch_job.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminConfirmBatchJob } from "medusa-react"

    type Props = { batchJobId: string }

    const BatchJob = ({ batchJobId }: Props) => { const confirmBatchJob = useAdminConfirmBatchJob(batchJobId) // ...

    const handleConfirm = () => { confirmBatchJob.mutate(undefined, { onSuccess: ({ batch_job }) => { console.log(batch_job) } }) }

    // ... }

    export default BatchJob

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/batch-jobs/{id}/confirm' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Batch Jobs

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminBatchJobRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Batch) Create

func (m *Batch) Create(context fiber.Ctx) error

@oas:path [post] /admin/batch-jobs operationId: "PostBatchJobs" summary: "Create a Batch Job" description: "Create a Batch Job to be executed asynchronously in the Medusa backend. If `dry_run` is set to `true`, the batch job will not be executed until the it is confirmed,

which can be done using the Confirm Batch Job API Route."

externalDocs:

description: "How to create a batch job"
url: "https://docs.medusajs.com/development/batch-jobs/create#create-batch-job"

x-authenticated: true requestBody:

content:
 application/json:
   schema:
     $ref: "#/components/schemas/AdminPostBatchesReq"

x-codegen:

method: 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.batchJobs.create({ type: 'product-export', context: {}, dry_run: false }).then((({ batch_job }) => { console.log(batch_job.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateBatchJob } from "medusa-react"

    const CreateBatchJob = () => { const createBatchJob = useAdminCreateBatchJob() // ...

    const handleCreateBatchJob = () => { createBatchJob.mutate({ type: "publish-products", context: {}, dry_run: true }, { onSuccess: ({ batch_job }) => { console.log(batch_job) } }) }

    // ... }

    export default CreateBatchJob

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/batch-jobs' \ -H 'Content-Type: application/json' \ -H 'x-medusa-access-token: "{api_token}"' \ --data-raw '{ "type": "product-export", "context": { } }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Batch Jobs

responses:

201:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminBatchJobRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Batch) Get

func (m *Batch) Get(context fiber.Ctx) error

@oas:path [get] /admin/batch-jobs/{id} operationId: "GetBatchJobsBatchJob" summary: "Get a Batch Job" description: "Retrieve the details of a batch job." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Batch Job

x-codegen:

method: 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.batchJobs.retrieve(batchJobId) .then(({ batch_job }) => { console.log(batch_job.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminBatchJob } from "medusa-react"

    type Props = { batchJobId: string }

    const BatchJob = ({ batchJobId }: Props) => { const { batch_job, isLoading } = useAdminBatchJob(batchJobId)

    return ( <div> {isLoading && <span>Loading...</span>} {batch_job && <span>{batch_job.created_by}</span>} </div> ) }

    export default BatchJob

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/batch-jobs/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Batch Jobs

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminBatchJobRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Batch) List

func (m *Batch) List(context fiber.Ctx) error

@oas:path [get] /admin/batch-jobs operationId: "GetBatchJobs" summary: "List Batch Jobs" description: "Retrieve a list of Batch Jobs. The batch jobs can be filtered by fields such as `type` or `confirmed_at`. The batch jobs can also be sorted or paginated." x-authenticated: true parameters:

  • (query) limit=10 {integer} Limit the number of batch jobs returned.
  • (query) offset=0 {integer} The number of batch jobs to skip when retrieving the batch jobs.
  • in: query name: id style: form explode: false description: Filter by the batch ID schema: oneOf:
  • type: string description: batch job ID
  • type: array description: multiple batch job IDs items: type: string
  • in: query name: type style: form explode: false description: Filter by the batch type schema: type: array items: type: string
  • in: query name: confirmed_at style: form explode: false description: Filter by a confirmation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: pre_processed_at style: form explode: false description: Filter by a pre-processing date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: completed_at style: form explode: false description: Filter by a completion date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: failed_at style: form explode: false description: Filter by a failure date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: canceled_at style: form explode: false description: Filter by a cancelation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • (query) order {string} A batch-job field to sort-order the retrieved batch jobs by.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned batch jobs.
  • (query) fields {string} Comma-separated fields that should be included in the returned batch jobs.
  • in: query name: created_at style: form explode: false description: Filter by a creation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: updated_at style: form explode: false description: Filter by an update date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date

x-codegen:

method: list
queryParams: AdminGetBatchParams

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: tsx label: Medusa React source: | import React from "react" import { useAdminBatchJobs } from "medusa-react"

    const BatchJobs = () => { const { batch_jobs, limit, offset, count, isLoading } = useAdminBatchJobs()

    return ( <div> {isLoading && <span>Loading...</span>} {batch_jobs?.length && ( <ul> {batch_jobs.map((batchJob) => ( <li key={batchJob.id}> {batchJob.id} </li> ))} </ul> )} </div> ) }

    export default BatchJobs

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/batch-jobs' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Batch Jobs

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminBatchJobListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Batch) SetRoutes

func (m *Batch) SetRoutes(router fiber.Router)

type Collection

type Collection struct {
	// contains filtered or unexported fields
}

func NewCollection

func NewCollection(r Registry) *Collection

func (*Collection) AddProducts

func (m *Collection) AddProducts(context fiber.Ctx) error

@oas:path [post] /admin/collections/{id}/products/batch operationId: "PostProductsToCollection" summary: "Add Products to Collection" description: "Add products to a product collection." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the product collection.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostProductsToCollectionReq"

x-codegen:

method: addProducts

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.addProducts(collectionId, { product_ids: [ productId1, productId2 ] }) .then(({ collection }) => { console.log(collection.products) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminAddProductsToCollection } from "medusa-react"

    type Props = { collectionId: string }

    const Collection = ({ collectionId }: Props) => { const addProducts = useAdminAddProductsToCollection(collectionId) // ...

    const handleAddProducts = (productIds: string[]) => { addProducts.mutate({ product_ids: productIds }, { onSuccess: ({ collection }) => { console.log(collection.products) } }) }

    // ... }

    export default Collection

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/collections/{id}/products/batch' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "product_ids": [ "prod_01G1G5V2MBA328390B5AXJ610F" ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Product Collections

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminCollectionsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Collection) Create

func (m *Collection) Create(context fiber.Ctx) error

@oas:path [post] /admin/collections operationId: "PostCollections" summary: "Create a Collection" description: "Create a Product Collection." x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostCollectionsReq"

x-codegen:

method: 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.collections.create({ title: "New Collection" }) .then(({ collection }) => { console.log(collection.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateCollection } from "medusa-react"

    const CreateCollection = () => { const createCollection = useAdminCreateCollection() // ...

    const handleCreate = (title: string) => { createCollection.mutate({ title }, { onSuccess: ({ collection }) => { console.log(collection.id) } }) }

    // ... }

    export default CreateCollection

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/collections' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "title": "New Collection" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Product Collections

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminCollectionsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Collection) Delete

func (m *Collection) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/collections/{id} operationId: "DeleteCollectionsCollection" summary: "Delete a Collection" description: "Delete a Product Collection. This does not delete associated products." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Collection.

x-codegen:

method: 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.collections.delete(collectionId) .then(({ id, object, deleted }) => { console.log(id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteCollection } from "medusa-react"

    type Props = { collectionId: string }

    const Collection = ({ collectionId }: Props) => { const deleteCollection = useAdminDeleteCollection(collectionId) // ...

    const handleDelete = (title: string) => { deleteCollection.mutate(void 0, { onSuccess: ({ id, object, deleted }) => { console.log(id) } }) }

    // ... }

    export default Collection

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/collections/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Product Collections

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminCollectionsDeleteRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Collection) Get

func (m *Collection) Get(context fiber.Ctx) error

@oas:path [get] /admin/collections/{id} operationId: "GetCollectionsCollection" summary: "Get a Collection" description: "Retrieve a Product Collection by its ID. The products associated with it are expanded and returned as well." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Product Collection

x-codegen:

method: 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.collections.retrieve(collectionId) .then(({ collection }) => { console.log(collection.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCollection } from "medusa-react"

    type Props = { collectionId: string }

    const Collection = ({ collectionId }: Props) => { const { collection, isLoading } = useAdminCollection(collectionId)

    return ( <div> {isLoading && <span>Loading...</span>} {collection && <span>{collection.title}</span>} </div> ) }

    export default Collection

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/collections/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Product Collections

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminCollectionsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Collection) List

func (m *Collection) List(context fiber.Ctx) error

@oas:path [get] /admin/collections operationId: "GetCollections" summary: "List Collections" description: "Retrieve a list of Product Collection. The product collections can be filtered by fields such as `handle` or `title`. The collections can also be sorted or paginated." x-authenticated: true parameters:

  • (query) limit=10 {integer} The number of collections to return.
  • (query) offset=0 {integer} The number of collections to skip when retrieving the collections.
  • (query) title {string} Filter collections by their title.
  • (query) handle {string} Filter collections by their handle.
  • (query) q {string} a term to search collections by their title or handle.
  • (query) discount_condition_id {string} Filter collections by a discount condition ID associated with them.
  • in: query name: created_at description: Filter by a creation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: updated_at description: Filter by an update date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: deleted_at description: Filter by a deletion date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date

x-codegen:

method: list
queryParams: AdminGetCollectionsParams

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: tsx label: Medusa React source: | import React from "react" import { useAdminCollections } from "medusa-react"

    const Collections = () => { const { collections, isLoading } = useAdminCollections()

    return ( <div> {isLoading && <span>Loading...</span>} {collections && !collections.length && <span> No Product Collections </span>} {collections && collections.length > 0 && ( <ul> {collections.map((collection) => ( <li key={collection.id}>{collection.title}</li> ))} </ul> )} </div> ) }

    export default Collections

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/collections' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Product Collections

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminCollectionsListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Collection) RemoveProducts

func (m *Collection) RemoveProducts(context fiber.Ctx) error

@oas:path [delete] /admin/collections/{id}/products/batch operationId: "DeleteProductsFromCollection" summary: "Remove Products from Collection" description: "Remove a list of products from a collection. This would not delete the product, only the association between the product and the collection." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Product Collection.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminDeleteProductsFromCollectionReq"

x-codegen:

method: removeProducts

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.removeProducts(collectionId, { product_ids: [ productId1, productId2 ] }) .then(({ id, object, removed_products }) => { console.log(removed_products) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminRemoveProductsFromCollection } from "medusa-react"

    type Props = { collectionId: string }

    const Collection = ({ collectionId }: Props) => { const removeProducts = useAdminRemoveProductsFromCollection(collectionId) // ...

    const handleRemoveProducts = (productIds: string[]) => { removeProducts.mutate({ product_ids: productIds }, { onSuccess: ({ id, object, removed_products }) => { console.log(removed_products) } }) }

    // ... }

    export default Collection

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/collections/{id}/products/batch' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "product_ids": [ "prod_01G1G5V2MBA328390B5AXJ610F" ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Product Collections

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDeleteProductsFromCollectionRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Collection) SetRoutes

func (m *Collection) SetRoutes(router fiber.Router)

func (*Collection) Update

func (m *Collection) Update(context fiber.Ctx) error

@oas:path [post] /admin/collections/{id} operationId: "PostCollectionsCollection" summary: "Update a Collection" description: "Update a Product Collection's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Collection.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostCollectionsCollectionReq"

x-codegen:

method: update

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(collectionId, { title: "New Collection" }) .then(({ collection }) => { console.log(collection.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateCollection } from "medusa-react"

    type Props = { collectionId: string }

    const Collection = ({ collectionId }: Props) => { const updateCollection = useAdminUpdateCollection(collectionId) // ...

    const handleUpdate = (title: string) => { updateCollection.mutate({ title }, { onSuccess: ({ collection }) => { console.log(collection.id) } }) }

    // ... }

    export default Collection

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/collections/{id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "title": "New Collection" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Product Collections

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminCollectionsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type Currencie

type Currencie struct {
	// contains filtered or unexported fields
}

func NewCurrencie

func NewCurrencie(r Registry) *Currencie

func (*Currencie) List

func (m *Currencie) List(context fiber.Ctx) error

@oas:path [get] /admin/currencies operationId: "GetCurrencies" summary: "List Currency" description: "Retrieve a list of currencies. The currencies can be filtered by fields such as `code`. The currencies can also be sorted or paginated." x-authenticated: true parameters:

  • (query) code {string} filter by currency code.
  • in: query name: includes_tax description: filter currencies by whether they include taxes or not. schema: type: boolean x-featureFlag: "tax_inclusive_pricing"
  • (query) order {string} A field to sort order the retrieved currencies by.
  • (query) q {string} Term used to search currencies' name and code.
  • (query) offset=0 {number} The number of currencies to skip when retrieving the currencies.
  • (query) limit=20 {number} The number of currencies to return.

x-codegen:

method: list
queryParams: AdminGetCurrenciesParams

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.currencies.list() .then(({ currencies, count, offset, limit }) => { console.log(currencies.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCurrencies } from "medusa-react"

    const Currencies = () => { const { currencies, isLoading } = useAdminCurrencies()

    return ( <div> {isLoading && <span>Loading...</span>} {currencies && !currencies.length && ( <span>No Currencies</span> )} {currencies && currencies.length > 0 && ( <ul> {currencies.map((currency) => ( <li key={currency.code}>{currency.name}</li> ))} </ul> )} </div> ) }

    export default Currencies

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/currencies' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Currencies

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminCurrenciesListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Currencie) SetRoutes

func (m *Currencie) SetRoutes(router fiber.Router)

func (*Currencie) Update

func (m *Currencie) Update(context fiber.Ctx) error

@oas:path [post] /admin/currencies/{code} operationId: "PostCurrenciesCurrency" summary: "Update a Currency" description: "Update a Currency's details." x-authenticated: true parameters:

  • (path) code=* {string} The code of the Currency.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostCurrenciesCurrencyReq"

x-codegen:

method: update

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.currencies.update(code, { includes_tax: true }) .then(({ currency }) => { console.log(currency.code); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateCurrency } from "medusa-react"

    type Props = { currencyCode: string }

    const Currency = ({ currencyCode }: Props) => { const updateCurrency = useAdminUpdateCurrency(currencyCode) // ...

    const handleUpdate = (includes_tax: boolean) => { updateCurrency.mutate({ includes_tax, }, { onSuccess: ({ currency }) => { console.log(currency) } }) }

    // ... }

    export default Currency

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/currencies/{code}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "includes_tax": true }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Currencies

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminCurrenciesRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type Customer

type Customer struct {
	// contains filtered or unexported fields
}

func NewCustomer

func NewCustomer(r Registry) *Customer

func (*Customer) Create

func (m *Customer) Create(context fiber.Ctx) error

@oas:path [post] /admin/customers operationId: "PostCustomers" summary: "Create a Customer" description: "Create a customer as an admin." x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostCustomersReq"

x-codegen:

method: 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.customers.create({ email: "[email protected]", first_name: "Caterina", last_name: "Yost", password: "supersecret" }) .then(({ customer }) => { console.log(customer.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateCustomer } from "medusa-react"

    type CustomerData = { first_name: string last_name: string email: string password: string }

    const CreateCustomer = () => { const createCustomer = useAdminCreateCustomer() // ...

    const handleCreate = (customerData: CustomerData) => { createCustomer.mutate(customerData, { onSuccess: ({ customer }) => { console.log(customer.id) } }) }

    // ... }

    export default CreateCustomer

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/customers' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "email": "[email protected]", "first_name": "Caterina", "last_name": "Yost", "password": "supersecret" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Customers

responses:

201:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminCustomersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Customer) Get

func (m *Customer) Get(context fiber.Ctx) error

@oas:path [get] /admin/customers/{id} operationId: "GetCustomersCustomer" summary: "Get a Customer" description: "Retrieve the details of a customer." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Customer.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned customer.
  • (query) fields {string} Comma-separated fields that should be included in the returned customer.

x-codegen:

method: 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.customers.retrieve(customerId) .then(({ customer }) => { console.log(customer.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCustomer } from "medusa-react"

    type Props = { customerId: string }

    const Customer = ({ customerId }: Props) => { const { customer, isLoading } = useAdminCustomer( customerId )

    return ( <div> {isLoading && <span>Loading...</span>} {customer && <span>{customer.first_name}</span>} </div> ) }

    export default Customer

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/customers/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Customers

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminCustomersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Customer) List

func (m *Customer) List(context fiber.Ctx) error

@oas:path [get] /admin/customers operationId: "GetCustomers" summary: "List Customers" description: "Retrieve a list of Customers. The customers can be filtered by fields such as `q` or `groups`. The customers can also be paginated." x-authenticated: true parameters:

  • (query) limit=50 {integer} The number of customers to return.
  • (query) offset=0 {integer} The number of customers to skip when retrieving the customers.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned customer.
  • (query) q {string} term to search customers' email, first_name, and last_name fields.
  • in: query name: groups style: form explode: false description: Filter by customer group IDs. schema: type: array items: type: string

x-codegen:

method: list
queryParams: AdminGetCustomersParams

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: tsx label: Medusa React source: | import React from "react" import { useAdminCustomers } from "medusa-react"

    const Customers = () => { const { customers, isLoading } = useAdminCustomers()

    return ( <div> {isLoading && <span>Loading...</span>} {customers && !customers.length && ( <span>No customers</span> )} {customers && customers.length > 0 && ( <ul> {customers.map((customer) => ( <li key={customer.id}>{customer.first_name}</li> ))} </ul> )} </div> ) }

    export default Customers

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/customers' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Customers

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminCustomersListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Customer) SetRoutes

func (m *Customer) SetRoutes(router fiber.Router)

func (*Customer) Update

func (m *Customer) Update(context fiber.Ctx) error

@oas:path [post] /admin/customers/{id} operationId: "PostCustomersCustomer" summary: "Update a Customer" description: "Update a Customer's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Customer.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned customer.
  • (query) fields {string} Comma-separated fields that should be retrieved in the returned customer.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostCustomersCustomerReq"

x-codegen:

method: update

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(customerId, { first_name: "Dolly" }) .then(({ customer }) => { console.log(customer.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateCustomer } from "medusa-react"

    type CustomerData = { first_name: string last_name: string email: string password: string }

    type Props = { customerId: string }

    const Customer = ({ customerId }: Props) => { const updateCustomer = useAdminUpdateCustomer(customerId) // ...

    const handleUpdate = (customerData: CustomerData) => { updateCustomer.mutate(customerData) }

    // ... }

    export default Customer

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/customers/{id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "first_name": "Dolly" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Customers

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminCustomersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type CustomerGroup

type CustomerGroup struct {
	// contains filtered or unexported fields
}

func NewCustomerGroup

func NewCustomerGroup(r Registry) *CustomerGroup

func (*CustomerGroup) AddCustomers

func (m *CustomerGroup) AddCustomers(context fiber.Ctx) error

@oas:path [post] /admin/customer-groups/{id}/customers/batch operationId: "PostCustomerGroupsGroupCustomersBatch" summary: "Add Customers to Group" description: "Add a list of customers to a customer group." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the customer group.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostCustomerGroupsGroupCustomersBatchReq"

x-codegen:

method: addCustomers

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(customerGroupId, { customer_ids: [ { id: customerId } ] }) .then(({ customer_group }) => { console.log(customer_group.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminAddCustomersToCustomerGroup, } from "medusa-react"

    type Props = { customerGroupId: string }

    const CustomerGroup = ({ customerGroupId }: Props) => { const addCustomers = useAdminAddCustomersToCustomerGroup( customerGroupId ) // ...

    const handleAddCustomers= (customerId: string) => { addCustomers.mutate({ customer_ids: [ { id: customerId, }, ], }) }

    // ... }

    export default CustomerGroup

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/customer-groups/{id}/customers/batch' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "customer_ids": [ { "id": "cus_01G2Q4BS9GAHDBMDEN4ZQZCJB2" } ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Customer Groups

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminCustomerGroupsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*CustomerGroup) Create

func (m *CustomerGroup) Create(context fiber.Ctx) error

@oas:path [post] /admin/customer-groups operationId: "PostCustomerGroups" summary: "Create a Customer Group" description: "Create a Customer Group." x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostCustomerGroupsReq"

x-codegen:

method: 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.customerGroups.create({ name: "VIP" }) .then(({ customer_group }) => { console.log(customer_group.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateCustomerGroup } from "medusa-react"

    const CreateCustomerGroup = () => { const createCustomerGroup = useAdminCreateCustomerGroup() // ...

    const handleCreate = (name: string) => { createCustomerGroup.mutate({ name, }) }

    // ... }

    export default CreateCustomerGroup

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/customer-groups' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "name": "VIP" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Customer Groups

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminCustomerGroupsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*CustomerGroup) Delete

func (m *CustomerGroup) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/customer-groups/{id} operationId: "DeleteCustomerGroupsCustomerGroup" summary: "Delete a Customer Group" description: "Delete a customer group. This doesn't delete the customers associated with the customer group." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Customer Group

x-codegen:

method: 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.customerGroups.delete(customerGroupId) .then(({ id, object, deleted }) => { console.log(id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteCustomerGroup } from "medusa-react"

    type Props = { customerGroupId: string }

    const CustomerGroup = ({ customerGroupId }: Props) => { const deleteCustomerGroup = useAdminDeleteCustomerGroup( customerGroupId ) // ...

    const handleDeleteCustomerGroup = () => { deleteCustomerGroup.mutate() }

    // ... }

    export default CustomerGroup

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/customer-groups/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Customer Groups

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminCustomerGroupsDeleteRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*CustomerGroup) DeleteCustomers

func (m *CustomerGroup) DeleteCustomers(context fiber.Ctx) error

@oas:path [delete] /admin/customer-groups/{id}/customers/batch operationId: "DeleteCustomerGroupsGroupCustomerBatch" summary: "Remove Customers from Group" description: "Remove a list of customers from a customer group. This doesn't delete the customer, only the association between the customer and the customer group." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the customer group.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminDeleteCustomerGroupsGroupCustomerBatchReq"

x-codegen:

method: removeCustomers

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(customerGroupId, { customer_ids: [ { id: customerId } ] }) .then(({ customer_group }) => { console.log(customer_group.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminRemoveCustomersFromCustomerGroup, } from "medusa-react"

    type Props = { customerGroupId: string }

    const CustomerGroup = ({ customerGroupId }: Props) => { const removeCustomers = useAdminRemoveCustomersFromCustomerGroup( customerGroupId ) // ...

    const handleRemoveCustomer = (customerId: string) => { removeCustomers.mutate({ customer_ids: [ { id: customerId, }, ], }) }

    // ... }

    export default CustomerGroup

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/customer-groups/{id}/customers/batch' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "customer_ids": [ { "id": "cus_01G2Q4BS9GAHDBMDEN4ZQZCJB2" } ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Customer Groups

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminCustomerGroupsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*CustomerGroup) Get

func (m *CustomerGroup) Get(context fiber.Ctx) error

@oas:path [get] /admin/customer-groups/{id} operationId: "GetCustomerGroupsGroup" summary: "Get a Customer Group" description: "Retrieve a Customer Group by its ID. You can expand the customer group's relations or select the fields that should be returned." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Customer Group.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned customer group.
  • (query) fields {string} Comma-separated fields that should be included in the returned customer group.

x-codegen:

method: retrieve
queryParams: AdminGetCustomerGroupsGroupParams

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(customerGroupId) .then(({ customer_group }) => { console.log(customer_group.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCustomerGroup } from "medusa-react"

    type Props = { customerGroupId: string }

    const CustomerGroup = ({ customerGroupId }: Props) => { const { customer_group, isLoading } = useAdminCustomerGroup( customerGroupId )

    return ( <div> {isLoading && <span>Loading...</span>} {customer_group && <span>{customer_group.name}</span>} </div> ) }

    export default CustomerGroup

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/customer-groups/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Customer Groups

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminCustomerGroupsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*CustomerGroup) GetBatch

func (m *CustomerGroup) GetBatch(context fiber.Ctx) error

@oas:path [get] /admin/customer-groups/{id}/customers operationId: "GetCustomerGroupsGroupCustomers" summary: "List Customers" description: "Retrieve a list of customers in a customer group. The customers can be filtered by the `q` field. The customers can also be paginated." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the customer group.
  • (query) limit=50 {integer} The number of customers to return.
  • (query) offset=0 {integer} The number of customers to skip when retrieving the customers.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned customers.
  • (query) q {string} a term to search customers by email, first_name, and last_name.

x-codegen:

method: listCustomers
queryParams: AdminGetGroupsGroupCustomersParams

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(customerGroupId) .then(({ customers }) => { console.log(customers.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCustomerGroupCustomers } from "medusa-react"

    type Props = { customerGroupId: string }

    const CustomerGroup = ({ customerGroupId }: Props) => { const { customers, isLoading, } = useAdminCustomerGroupCustomers( customerGroupId )

    return ( <div> {isLoading && <span>Loading...</span>} {customers && !customers.length && ( <span>No customers</span> )} {customers && customers.length > 0 && ( <ul> {customers.map((customer) => ( <li key={customer.id}>{customer.first_name}</li> ))} </ul> )} </div> ) }

    export default CustomerGroup

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/customer-groups/{id}/customers' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Customer Groups

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminCustomersListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*CustomerGroup) List

func (m *CustomerGroup) List(context fiber.Ctx) error

@oas:path [get] /admin/customer-groups operationId: "GetCustomerGroups" summary: "List Customer Groups" description: "Retrieve a list of customer groups. The customer groups can be filtered by fields such as `name` or `id. The customer groups can also be sorted or paginated." x-authenticated: true parameters:

  • (query) q {string} term to search customer groups by name.
  • (query) offset=0 {integer} The number of customer groups to skip when retrieving the customer groups.
  • (query) order {string} A field to sort order the retrieved customer groups by.
  • (query) discount_condition_id {string} Filter by discount condition ID.
  • in: query name: id style: form explode: false description: Filter by the customer group ID schema: oneOf:
  • type: string description: customer group ID
  • type: array description: an array of customer group IDs items: type: string
  • type: object properties: lt: type: string description: filter by IDs less than this ID gt: type: string description: filter by IDs greater than this ID lte: type: string description: filter by IDs less than or equal to this ID gte: type: string description: filter by IDs greater than or equal to this ID
  • in: query name: name style: form explode: false description: Filter by the customer group name schema: type: array description: an array of customer group names items: type: string description: customer group name
  • in: query name: created_at description: Filter by a creation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: updated_at description: Filter by an update date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • (query) limit=10 {integer} The number of customer groups to return.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned customer groups.

x-codegen:

method: list
queryParams: AdminGetCustomerGroupsParams

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.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCustomerGroups } from "medusa-react"

    const CustomerGroups = () => { const { customer_groups, isLoading, } = useAdminCustomerGroups()

    return ( <div> {isLoading && <span>Loading...</span>} {customer_groups && !customer_groups.length && ( <span>No Customer Groups</span> )} {customer_groups && customer_groups.length > 0 && ( <ul> {customer_groups.map( (customerGroup) => ( <li key={customerGroup.id}> {customerGroup.name} </li> ) )} </ul> )} </div> ) }

    export default CustomerGroups

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/customer-groups' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Customer Groups

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminCustomerGroupsListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*CustomerGroup) SetRoutes

func (m *CustomerGroup) SetRoutes(router fiber.Router)

func (*CustomerGroup) Update

func (m *CustomerGroup) Update(context fiber.Ctx) error

@oas:path [post] /admin/customer-groups/{id} operationId: "PostCustomerGroupsGroup" summary: "Update a Customer Group" description: "Update a Customer Group's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the customer group.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostCustomerGroupsGroupReq"

x-codegen:

method: update

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(customerGroupId, { name: "VIP" }) .then(({ customer_group }) => { console.log(customer_group.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateCustomerGroup } from "medusa-react"

    type Props = { customerGroupId: string }

    const CustomerGroup = ({ customerGroupId }: Props) => { const updateCustomerGroup = useAdminUpdateCustomerGroup( customerGroupId ) // ..

    const handleUpdate = (name: string) => { updateCustomerGroup.mutate({ name, }) }

    // ... }

    export default CustomerGroup

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/customer-groups/{id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "name": "VIP" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Customer Groups

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminCustomerGroupsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type Discount

type Discount struct {
	// contains filtered or unexported fields
}

func NewDiscount

func NewDiscount(r Registry) *Discount

func (*Discount) AddRegion

func (m *Discount) AddRegion(context fiber.Ctx) error

@oas:path [post] /admin/discounts/{id}/regions/{region_id} operationId: "PostDiscountsDiscountRegionsRegion" summary: "Add Region to Discount" description: "Add a Region to the list of Regions a Discount can be used in." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Discount.
  • (path) region_id=* {string} The ID of the Region.

x-codegen:

method: addRegion

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(discountId, regionId) .then(({ discount }) => { console.log(discount.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDiscountAddRegion } from "medusa-react"

    type Props = { discountId: string }

    const Discount = ({ discountId }: Props) => { const addRegion = useAdminDiscountAddRegion(discountId) // ...

    const handleAdd = (regionId: string) => { addRegion.mutate(regionId, { onSuccess: ({ discount }) => { console.log(discount.regions) } }) }

    // ... }

    export default Discount

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/discounts/{id}/regions/{region_id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Discounts

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDiscountsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Discount) AddResourcesToConditionBatch

func (m *Discount) AddResourcesToConditionBatch(context fiber.Ctx) error

@oas:path [post] /admin/discounts/{discount_id}/conditions/{condition_id}/batch operationId: "PostDiscountsDiscountConditionsConditionBatch" summary: "Add Batch Resources" description: "Add a batch of resources to a discount condition. The type of resource depends on the type of discount condition. For example, if the discount condition's type is `products`, the resources being added should be products." x-authenticated: true parameters:

  • (path) discount_id=* {string} The ID of the discount the condition belongs to.
  • (path) condition_id=* {string} The ID of the discount condition on which to add the item.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned discount.
  • (query) fields {string} Comma-separated fields that should be included in the returned discount.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostDiscountsDiscountConditionsConditionBatchReq"

x-codegen:

method: addConditionResourceBatch
queryParams: AdminPostDiscountsDiscountConditionsConditionBatchParams

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.addConditionResourceBatch(discountId, conditionId, { resources: [{ id: itemId }] }) .then(({ discount }) => { console.log(discount.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminAddDiscountConditionResourceBatch } from "medusa-react"

    type Props = { discountId: string conditionId: string }

    const DiscountCondition = ({ discountId, conditionId }: Props) => { const addConditionResources = useAdminAddDiscountConditionResourceBatch( discountId, conditionId ) // ...

    const handleAdd = (itemId: string) => { addConditionResources.mutate({ resources: [ { id: itemId } ] }, { onSuccess: ({ discount }) => { console.log(discount.id) } }) }

    // ... }

    export default DiscountCondition

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/discounts/{id}/conditions/{condition_id}/batch' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "resources": [{ "id": "item_id" }] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Discounts

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDiscountsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Discount) Create

func (m *Discount) Create(context fiber.Ctx) error

func (*Discount) CreateConditon

func (m *Discount) CreateConditon(context fiber.Ctx) error

@oas:path [post] /admin/discounts/{discount_id}/conditions operationId: "PostDiscountsDiscountConditions" summary: "Create a Condition" description: "Create a Discount Condition. Only one of `products`, `product_types`, `product_collections`, `product_tags`, and `customer_groups` should be provided, based on the type of discount condition.

For example, if the discount condition's type is `products`, the `products` field should be provided in the request body."

x-authenticated: true parameters:

  • (path) discount_id=* {string} The ID of the discount.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned discount.
  • (query) fields {string} Comma-separated fields that should be included in the returned discount.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostDiscountsDiscountConditions"

x-codegen:

method: createCondition
queryParams: AdminPostDiscountsDiscountConditionsParams

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(discountId, { operator: DiscountConditionOperator.IN, products: [productId] }) .then(({ discount }) => { console.log(discount.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { DiscountConditionOperator } from "@medusajs/medusa" import { useAdminDiscountCreateCondition } from "medusa-react"

    type Props = { discountId: string }

    const Discount = ({ discountId }: Props) => { const createCondition = useAdminDiscountCreateCondition(discountId) // ...

    const handleCreateCondition = ( operator: DiscountConditionOperator, products: string[] ) => { createCondition.mutate({ operator, products }, { onSuccess: ({ discount }) => { console.log(discount.id) } }) }

    // ... }

    export default Discount

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/discounts/{id}/conditions' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "operator": "in" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Discounts

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDiscountsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Discount) CreateDynamicCode

func (m *Discount) CreateDynamicCode(context fiber.Ctx) error

@oas:path [post] /admin/discounts/{id}/dynamic-codes operationId: "PostDiscountsDiscountDynamicCodes" summary: "Create a Dynamic Code" description: "Create a dynamic unique code that can map to a parent Discount. This is useful if you want to automatically generate codes with the same rules and conditions." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Discount to create the dynamic code for."

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostDiscountsDiscountDynamicCodesReq"

x-codegen:

method: createDynamicCode

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(discountId, { code: "TEST", usage_limit: 1 }) .then(({ discount }) => { console.log(discount.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateDynamicDiscountCode } from "medusa-react"

    type Props = { discountId: string }

    const Discount = ({ discountId }: Props) => { const createDynamicDiscount = useAdminCreateDynamicDiscountCode(discountId) // ...

    const handleCreate = ( code: string, usageLimit: number ) => { createDynamicDiscount.mutate({ code, usage_limit: usageLimit }, { onSuccess: ({ discount }) => { console.log(discount.is_dynamic) } }) }

    // ... }

    export default Discount

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/discounts/{id}/dynamic-codes' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "code": "TEST" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Discounts

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDiscountsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Discount) Delete

func (m *Discount) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/discounts/{id} operationId: "DeleteDiscountsDiscount" summary: "Delete a Discount" description: "Delete a Discount. Deleting the discount will make it unavailable for customers to use." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Discount

x-codegen:

method: 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.discounts.delete(discountId) .then(({ id, object, deleted }) => { console.log(id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteDiscount } from "medusa-react"

    const Discount = () => { const deleteDiscount = useAdminDeleteDiscount(discount_id) // ...

    const handleDelete = () => { deleteDiscount.mutate() }

    // ... }

    export default Discount

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/discounts/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Discounts

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDiscountsDeleteRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Discount) DeleteConditon

func (m *Discount) DeleteConditon(context fiber.Ctx) error

@oas:path [delete] /admin/discounts/{discount_id}/conditions/{condition_id} operationId: "DeleteDiscountsDiscountConditionsCondition" summary: "Delete a Condition" description: "Delete a Discount Condition. This does not delete resources associated to the discount condition." x-authenticated: true parameters:

  • (path) discount_id=* {string} The ID of the Discount
  • (path) condition_id=* {string} The ID of the Discount Condition
  • (query) expand {string} Comma-separated relations that should be expanded in the returned discount.
  • (query) fields {string} Comma-separated fields that should be included in the returned discount.

x-codegen:

method: deleteCondition
queryParams: AdminDeleteDiscountsDiscountConditionsConditionParams

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(discountId, conditionId) .then(({ id, object, deleted }) => { console.log(id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDiscountRemoveCondition } from "medusa-react"

    type Props = { discountId: string }

    const Discount = ({ discountId }: Props) => { const deleteCondition = useAdminDiscountRemoveCondition( discountId ) // ...

    const handleDelete = ( conditionId: string ) => { deleteCondition.mutate(conditionId, { onSuccess: ({ id, object, deleted }) => { console.log(deleted) } }) }

    // ... }

    export default Discount

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/discounts/{id}/conditions/{condition_id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Discounts

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDiscountConditionsDeleteRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Discount) DeleteDynamicCode

func (m *Discount) DeleteDynamicCode(context fiber.Ctx) error

@oas:path [delete] /admin/discounts/{id}/dynamic-codes/{code} operationId: "DeleteDiscountsDiscountDynamicCodesCode" summary: "Delete a Dynamic Code" description: "Delete a dynamic code from a Discount." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Discount
  • (path) code=* {string} The dynamic code to delete

x-codegen:

method: deleteDynamicCode

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(discountId, code) .then(({ discount }) => { console.log(discount.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteDynamicDiscountCode } from "medusa-react"

    type Props = { discountId: string }

    const Discount = ({ discountId }: Props) => { const deleteDynamicDiscount = useAdminDeleteDynamicDiscountCode(discountId) // ...

    const handleDelete = (code: string) => { deleteDynamicDiscount.mutate(code, { onSuccess: ({ discount }) => { console.log(discount.is_dynamic) } }) }

    // ... }

    export default Discount

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/discounts/{id}/dynamic-codes/{code}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Discounts

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDiscountsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Discount) DeleteResourcesToConditionBatch

func (m *Discount) DeleteResourcesToConditionBatch(context fiber.Ctx) error

@oas:path [delete] /admin/discounts/{discount_id}/conditions/{condition_id}/batch operationId: "DeleteDiscountsDiscountConditionsConditionBatch" summary: "Remove Batch Resources" description: "Remove a batch of resources from a discount condition. This will only remove the association between the resource and the discount condition, not the resource itself." x-authenticated: true parameters:

  • (path) discount_id=* {string} The ID of the discount.
  • (path) condition_id=* {string} The ID of the condition to remove the resources from.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned discount.
  • (query) fields {string} Comma-separated fields that should be included in the returned discount.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminDeleteDiscountsDiscountConditionsConditionBatchReq"

x-codegen:

method: deleteConditionResourceBatch

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.deleteConditionResourceBatch(discountId, conditionId, { resources: [{ id: itemId }] }) .then(({ discount }) => { console.log(discount.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteDiscountConditionResourceBatch } from "medusa-react"

    type Props = { discountId: string conditionId: string }

    const DiscountCondition = ({ discountId, conditionId }: Props) => { const deleteConditionResource = useAdminDeleteDiscountConditionResourceBatch( discountId, conditionId, ) // ...

    const handleDelete = (itemId: string) => { deleteConditionResource.mutate({ resources: [ { id: itemId } ] }, { onSuccess: ({ discount }) => { console.log(discount.id) } }) }

    // ... }

    export default DiscountCondition

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/discounts/{id}/conditions/{condition_id}/batch' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "resources": [{ "id": "item_id" }] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Discounts

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDiscountsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Discount) Get

func (m *Discount) Get(context fiber.Ctx) error

@oas:path [get] /admin/discounts/{id} operationId: "GetDiscountsDiscount" summary: "Get a Discount" description: "Retrieve a Discount." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Discount
  • (query) expand {string} Comma-separated relations that should be expanded in the returned discount.
  • (query) fields {string} Comma-separated fields that should be included in the returned discount.

x-codegen:

method: retrieve
queryParams: AdminGetDiscountParams

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(discountId) .then(({ discount }) => { console.log(discount.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDiscount } from "medusa-react"

    type Props = { discountId: string }

    const Discount = ({ discountId }: Props) => { const { discount, isLoading } = useAdminDiscount( discountId )

    return ( <div> {isLoading && <span>Loading...</span>} {discount && <span>{discount.code}</span>} </div> ) }

    export default Discount

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/discounts/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Discounts

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDiscountsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Discount) GetConditon

func (m *Discount) GetConditon(context fiber.Ctx) error

@oas:path [get] /admin/discounts/{discount_id}/conditions/{condition_id} operationId: "GetDiscountsDiscountConditionsCondition" summary: "Get a Condition" description: "Retrieve a Discount Condition's details." x-authenticated: true parameters:

  • (path) discount_id=* {string} The ID of the Discount.
  • (path) condition_id=* {string} The ID of the Discount Condition.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned discount condition.
  • (query) fields {string} Comma-separated fields that should be included in the returned discount condition.

x-codegen:

method: getCondition
queryParams: AdminGetDiscountsDiscountConditionsConditionParams

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(discountId, conditionId) .then(({ discount_condition }) => { console.log(discount_condition.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminGetDiscountCondition } from "medusa-react"

    type Props = { discountId: string discountConditionId: string }

    const DiscountCondition = ({ discountId, discountConditionId }: Props) => { const { discount_condition, isLoading } = useAdminGetDiscountCondition( discountId, discountConditionId )

    return ( <div> {isLoading && <span>Loading...</span>} {discount_condition && ( <span>{discount_condition.type}</span> )} </div> ) }

    export default DiscountCondition

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/discounts/{id}/conditions/{condition_id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Discounts

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDiscountConditionsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Discount) GetDiscountByCode

func (m *Discount) GetDiscountByCode(context fiber.Ctx) error

@oas:path [get] /admin/discounts/code/{code} operationId: "GetDiscountsDiscountCode" summary: "Get Discount by Code" description: "Retrieve a Discount's details by its discount code" x-authenticated: true parameters:

  • (path) code=* {string} The code of the Discount
  • (query) expand {string} Comma-separated relations that should be expanded in the returned discount.
  • (query) fields {string} Comma-separated fields that should be included in the returned discount.

x-codegen:

method: retrieveByCode
queryParams: AdminGetDiscountsDiscountCodeParams

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: tsx label: Medusa React source: | import React from "react" import { useAdminGetDiscountByCode } from "medusa-react"

    type Props = { discountCode: string }

    const Discount = ({ discountCode }: Props) => { const { discount, isLoading } = useAdminGetDiscountByCode( discountCode )

    return ( <div> {isLoading && <span>Loading...</span>} {discount && <span>{discount.code}</span>} </div> ) }

    export default Discount

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/discounts/code/{code}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Discounts

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDiscountsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Discount) List

func (m *Discount) List(context fiber.Ctx) error

@oas:path [get] /admin/discounts operationId: "GetDiscounts" summary: "List Discounts" x-authenticated: true description: "Retrieve a list of Discounts. The discounts can be filtered by fields such as `rule` or `is_dynamic`. The discounts can also be paginated." parameters:

  • (query) q {string} term to search discounts' code field.
  • in: query name: rule description: Filter discounts by rule fields. schema: type: object properties: type: type: string enum: [fixed, percentage, free_shipping] description: "Filter discounts by type." allocation: type: string enum: [total, item] description: "Filter discounts by allocation type."
  • (query) is_dynamic {boolean} Filter discounts by whether they're dynamic or not.
  • (query) is_disabled {boolean} Filter discounts by whether they're disabled or not.
  • (query) limit=20 {number} The number of discounts to return
  • (query) offset=0 {number} The number of discounts to skip when retrieving the discounts.
  • (query) expand {string} Comma-separated relations that should be expanded in each returned discount.

x-codegen:

method: list
queryParams: AdminGetDiscountsParams

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: tsx label: Medusa React source: | import React from "react" import { useAdminDiscounts } from "medusa-react"

    const Discounts = () => { const { discounts, isLoading } = useAdminDiscounts()

    return ( <div> {isLoading && <span>Loading...</span>} {discounts && !discounts.length && ( <span>No customers</span> )} {discounts && discounts.length > 0 && ( <ul> {discounts.map((discount) => ( <li key={discount.id}>{discount.code}</li> ))} </ul> )} </div> ) }

    export default Discounts

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/discounts' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Discounts

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDiscountsListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Discount) RemoveRegion

func (m *Discount) RemoveRegion(context fiber.Ctx) error

@oas:path [delete] /admin/discounts/{id}/regions/{region_id} operationId: "DeleteDiscountsDiscountRegionsRegion" summary: "Remove Region" x-authenticated: true description: "Remove a Region from the list of Regions that a Discount can be used in. This does not delete a region, only the association between it and the discount." parameters:

  • (path) id=* {string} The ID of the Discount.
  • (path) region_id=* {string} The ID of the Region.

x-codegen:

method: removeRegion

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(discountId, regionId) .then(({ discount }) => { console.log(discount.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDiscountRemoveRegion } from "medusa-react"

    type Props = { discountId: string }

    const Discount = ({ discountId }: Props) => { const deleteRegion = useAdminDiscountRemoveRegion(discountId) // ...

    const handleDelete = (regionId: string) => { deleteRegion.mutate(regionId, { onSuccess: ({ discount }) => { console.log(discount.regions) } }) }

    // ... }

    export default Discount

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/discounts/{id}/regions/{region_id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Discounts

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDiscountsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Discount) SetRoutes

func (m *Discount) SetRoutes(router fiber.Router)

func (*Discount) Update

func (m *Discount) Update(context fiber.Ctx) error

@oas:path [post] /admin/discounts/{id} operationId: "PostDiscountsDiscount" summary: "Update a Discount" description: "Update a Discount with a given set of rules that define how the Discount is applied." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Discount.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned discount.
  • (query) fields {string} Comma-separated fields that should be retrieved in the returned discount.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostDiscountsDiscountReq"

x-codegen:

method: update
queryParams: AdminPostDiscountsDiscountParams

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(discountId, { code: "TEST" }) .then(({ discount }) => { console.log(discount.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateDiscount } from "medusa-react"

    type Props = { discountId: string }

    const Discount = ({ discountId }: Props) => { const updateDiscount = useAdminUpdateDiscount(discountId) // ...

    const handleUpdate = (isDisabled: boolean) => { updateDiscount.mutate({ is_disabled: isDisabled, }) }

    // ... }

    export default Discount

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/discounts/{id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "code": "TEST" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Discounts

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDiscountsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Discount) UpdateConditon

func (m *Discount) UpdateConditon(context fiber.Ctx) error

@oas:path [post] /admin/discounts/{discount_id}/conditions/{condition_id} operationId: "PostDiscountsDiscountConditionsCondition" summary: "Update a Condition" description: "Update a Discount Condition. Only one of `products`, `product_types`, `product_collections`, `product_tags`, and `customer_groups` should be provided, based on the type of discount condition.

For example, if the discount condition's type is `products`, the `products` field should be provided in the request body."

x-authenticated: true parameters:

  • (path) discount_id=* {string} The ID of the Discount.
  • (path) condition_id=* {string} The ID of the Discount Condition.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned discount.
  • (query) fields {string} Comma-separated fields that should be included in the returned discount.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostDiscountsDiscountConditionsCondition"

x-codegen:

method: updateCondition
queryParams: AdminPostDiscountsDiscountConditionsConditionParams

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(discountId, conditionId, { products: [ productId ] }) .then(({ discount }) => { console.log(discount.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDiscountUpdateCondition } from "medusa-react"

    type Props = { discountId: string conditionId: string }

    const DiscountCondition = ({ discountId, conditionId }: Props) => { const update = useAdminDiscountUpdateCondition( discountId, conditionId ) // ...

    const handleUpdate = ( products: string[] ) => { update.mutate({ products }, { onSuccess: ({ discount }) => { console.log(discount.id) } }) }

    // ... }

    export default DiscountCondition

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/discounts/{id}/conditions/{condition}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "products": [ "prod_01G1G5V2MBA328390B5AXJ610F" ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Discounts

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDiscountsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type DraftOrder

type DraftOrder struct {
	// contains filtered or unexported fields
}

func NewDraftOrder

func NewDraftOrder(r Registry) *DraftOrder

func (*DraftOrder) Create

func (m *DraftOrder) Create(context fiber.Ctx) error

@oas:path [post] /admin/draft-orders operationId: "PostDraftOrders" summary: "Create a Draft Order" description: "Create a Draft Order. A draft order is not transformed into an order until payment is captured." x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostDraftOrdersReq"

x-codegen:

method: 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.draftOrders.create({ email: "[email protected]", region_id, items: [ { quantity: 1 } ], shipping_methods: [ { option_id } ], }) .then(({ draft_order }) => { console.log(draft_order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateDraftOrder } from "medusa-react"

    type DraftOrderData = { email: string region_id: string items: { quantity: number, variant_id: string }[] shipping_methods: { option_id: string price: number }[] }

    const CreateDraftOrder = () => { const createDraftOrder = useAdminCreateDraftOrder() // ...

    const handleCreate = (data: DraftOrderData) => { createDraftOrder.mutate(data, { onSuccess: ({ draft_order }) => { console.log(draft_order.id) } }) }

    // ... }

    export default CreateDraftOrder

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/draft-orders' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "email": "[email protected]", "region_id": "{region_id}" "items": [ { "quantity": 1 } ], "shipping_methods": [ { "option_id": "{option_id}" } ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Draft Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDraftOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*DraftOrder) CreateLineItem

func (m *DraftOrder) CreateLineItem(context fiber.Ctx) error

@oas:path [post] /admin/draft-orders/{id}/line-items operationId: "PostDraftOrdersDraftOrderLineItems" summary: "Create a Line Item" description: "Create a Line Item in the Draft Order." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Draft Order.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostDraftOrdersDraftOrderLineItemsReq"

x-codegen:

method: addLineItem

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(draftOrderId, { quantity: 1 }) .then(({ draft_order }) => { console.log(draft_order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDraftOrderAddLineItem } from "medusa-react"

    type Props = { draftOrderId: string }

    const DraftOrder = ({ draftOrderId }: Props) => { const addLineItem = useAdminDraftOrderAddLineItem( draftOrderId ) // ...

    const handleAdd = (quantity: number) => { addLineItem.mutate({ quantity, }, { onSuccess: ({ draft_order }) => { console.log(draft_order.cart) } }) }

    // ... }

    export default DraftOrder

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/draft-orders/{id}/line-items' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "quantity": 1 }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Draft Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDraftOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*DraftOrder) Delete

func (m *DraftOrder) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/draft-orders/{id} operationId: DeleteDraftOrdersDraftOrder summary: Delete a Draft Order description: "Delete a Draft Order." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Draft Order.

x-codegen:

method: 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.draftOrders.delete(draftOrderId) .then(({ id, object, deleted }) => { console.log(id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteDraftOrder } from "medusa-react"

    type Props = { draftOrderId: string }

    const DraftOrder = ({ draftOrderId }: Props) => { const deleteDraftOrder = useAdminDeleteDraftOrder( draftOrderId ) // ...

    const handleDelete = () => { deleteDraftOrder.mutate(void 0, { onSuccess: ({ id, object, deleted }) => { console.log(id) } }) }

    // ... }

    export default DraftOrder

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/draft-orders/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Draft Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDraftOrdersDeleteRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*DraftOrder) DeleteLineItem

func (m *DraftOrder) DeleteLineItem(context fiber.Ctx) error

@oas:path [delete] /admin/draft-orders/{id}/line-items/{line_id} operationId: DeleteDraftOrdersDraftOrderLineItemsItem summary: Delete a Line Item description: "Delete a Line Item from a Draft Order." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Draft Order.
  • (path) line_id=* {string} The ID of the line item.

x-codegen:

method: removeLineItem

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(draftOrderId, itemId) .then(({ draft_order }) => { console.log(draft_order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDraftOrderRemoveLineItem } from "medusa-react"

    type Props = { draftOrderId: string }

    const DraftOrder = ({ draftOrderId }: Props) => { const deleteLineItem = useAdminDraftOrderRemoveLineItem( draftOrderId ) // ...

    const handleDelete = (itemId: string) => { deleteLineItem.mutate(itemId, { onSuccess: ({ draft_order }) => { console.log(draft_order.cart) } }) }

    // ... }

    export default DraftOrder

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/draft-orders/{id}/line-items/{line_id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Draft Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDraftOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*DraftOrder) Get

func (m *DraftOrder) Get(context fiber.Ctx) error

@oas:path [get] /admin/draft-orders/{id} operationId: "GetDraftOrdersDraftOrder" summary: "Get a Draft Order" description: "Retrieve a Draft Order's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Draft Order.

x-codegen:

method: 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.draftOrders.retrieve(draftOrderId) .then(({ draft_order }) => { console.log(draft_order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDraftOrder } from "medusa-react"

    type Props = { draftOrderId: string }

    const DraftOrder = ({ draftOrderId }: Props) => { const { draft_order, isLoading, } = useAdminDraftOrder(draftOrderId)

    return ( <div> {isLoading && <span>Loading...</span>} {draft_order && <span>{draft_order.display_id}</span>}

    </div> ) }

    export default DraftOrder

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/draft-orders/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Draft Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDraftOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*DraftOrder) List

func (m *DraftOrder) List(context fiber.Ctx) error

@oas:path [get] /admin/draft-orders operationId: "GetDraftOrders" summary: "List Draft Orders" description: "Retrieve an list of Draft Orders. The draft orders can be filtered by fields such as `q`. The draft orders can also paginated." x-authenticated: true parameters:

  • (query) offset=0 {number} The number of draft orders to skip when retrieving the draft orders.
  • (query) limit=50 {number} Limit the number of draft orders returned.
  • (query) q {string} a term to search draft orders' display IDs and emails in the draft order's cart

x-codegen:

method: list
queryParams: AdminGetDraftOrdersParams

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: tsx label: Medusa React source: | import React from "react" import { useAdminDraftOrders } from "medusa-react"

    const DraftOrders = () => { const { draft_orders, isLoading } = useAdminDraftOrders()

    return ( <div> {isLoading && <span>Loading...</span>} {draft_orders && !draft_orders.length && ( <span>No Draft Orders</span> )} {draft_orders && draft_orders.length > 0 && ( <ul> {draft_orders.map((order) => ( <li key={order.id}>{order.display_id}</li> ))} </ul> )} </div> ) }

    export default DraftOrders

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/draft-orders' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Draft Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDraftOrdersListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*DraftOrder) RegisterPayment

func (m *DraftOrder) RegisterPayment(context fiber.Ctx) error

@oas:path [post] /admin/draft-orders/{id}/pay summary: "Mark Paid" operationId: "PostDraftOrdersDraftOrderRegisterPayment" description: "Capture the draft order's payment. This will also set the draft order's status to `completed` and create an Order from the draft order. The payment is captured through Medusa's system payment,

which is manual payment that isn't integrated with any third-party payment provider. It is assumed that the payment capturing is handled manually by the admin."

x-authenticated: true parameters:

  • (path) id=* {string} The Draft Order ID.

x-codegen:

method: markPaid

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(draftOrderId) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDraftOrderRegisterPayment } from "medusa-react"

    type Props = { draftOrderId: string }

    const DraftOrder = ({ draftOrderId }: Props) => { const registerPayment = useAdminDraftOrderRegisterPayment( draftOrderId ) // ...

    const handlePayment = () => { registerPayment.mutate(void 0, { onSuccess: ({ order }) => { console.log(order.id) } }) }

    // ... }

    export default DraftOrder

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/draft-orders/{id}/pay' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Draft Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPostDraftOrdersDraftOrderRegisterPaymentRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*DraftOrder) SetRoutes

func (m *DraftOrder) SetRoutes(router fiber.Router)

func (*DraftOrder) Update

func (m *DraftOrder) Update(context fiber.Ctx) error

@oas:path [post] /admin/draft-orders/{id} operationId: PostDraftOrdersDraftOrder summary: Update a Draft Order description: "Update a Draft Order's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Draft Order.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostDraftOrdersDraftOrderReq"

x-codegen:

method: update

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(draftOrderId, { email: "[email protected]" }) .then(({ draft_order }) => { console.log(draft_order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateDraftOrder } from "medusa-react"

    type Props = { draftOrderId: string }

    const DraftOrder = ({ draftOrderId }: Props) => { const updateDraftOrder = useAdminUpdateDraftOrder( draftOrderId ) // ...

    const handleUpdate = (email: string) => { updateDraftOrder.mutate({ email, }, { onSuccess: ({ draft_order }) => { console.log(draft_order.id) } }) }

    // ... }

    export default DraftOrder

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/draft-orders/{id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "email": "[email protected]" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Draft Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDraftOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*DraftOrder) UpdateLineItem

func (m *DraftOrder) UpdateLineItem(context fiber.Ctx) error

@oas:path [post] /admin/draft-orders/{id}/line-items/{line_id} operationId: "PostDraftOrdersDraftOrderLineItemsItem" summary: "Update a Line Item" description: "Update a Line Item in a Draft Order." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Draft Order.
  • (path) line_id=* {string} The ID of the Line Item.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostDraftOrdersDraftOrderLineItemsItemReq"

x-codegen:

method: updateLineItem

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(draftOrderId, lineId, { quantity: 1 }) .then(({ draft_order }) => { console.log(draft_order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDraftOrderUpdateLineItem } from "medusa-react"

    type Props = { draftOrderId: string }

    const DraftOrder = ({ draftOrderId }: Props) => { const updateLineItem = useAdminDraftOrderUpdateLineItem( draftOrderId ) // ...

    const handleUpdate = ( itemId: string, quantity: number ) => { updateLineItem.mutate({ item_id: itemId, quantity, }) }

    // ... }

    export default DraftOrder

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/draft-orders/{id}/line-items/{line_id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "quantity": 1 }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Draft Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDraftOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type GiftCard

type GiftCard struct {
	// contains filtered or unexported fields
}

func NewGiftCard

func NewGiftCard(r Registry) *GiftCard

func (*GiftCard) Create

func (m *GiftCard) Create(context fiber.Ctx) error

@oas:path [post] /admin/gift-cards operationId: "PostGiftCards" summary: "Create a Gift Card" description: "Create a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region." x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostGiftCardsReq"

x-codegen:

method: 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.giftCards.create({ region_id }) .then(({ gift_card }) => { console.log(gift_card.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateGiftCard } from "medusa-react"

    const CreateCustomGiftCards = () => { const createGiftCard = useAdminCreateGiftCard() // ...

    const handleCreate = ( regionId: string, value: number ) => { createGiftCard.mutate({ region_id: regionId, value, }, { onSuccess: ({ gift_card }) => { console.log(gift_card.id) } }) }

    // ... }

    export default CreateCustomGiftCards

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/gift-cards' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "region_id": "{region_id}" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Gift Cards

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminGiftCardsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*GiftCard) Delete

func (m *GiftCard) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/gift-cards/{id} operationId: "DeleteGiftCardsGiftCard" summary: "Delete a Gift Card" description: "Delete a Gift Card. Once deleted, it can't be used by customers." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Gift Card to delete.

x-codegen:

method: 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(giftCardId) .then(({ id, object, deleted }) => { console.log(id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteGiftCard } from "medusa-react"

    type Props = { customGiftCardId: string }

    const CustomGiftCard = ({ customGiftCardId }: Props) => { const deleteGiftCard = useAdminDeleteGiftCard( customGiftCardId ) // ...

    const handleDelete = () => { deleteGiftCard.mutate(void 0, { onSuccess: ({ id, object, deleted}) => { console.log(id) } }) }

    // ... }

    export default CustomGiftCard

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/gift-cards/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Gift Cards

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminGiftCardsDeleteRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*GiftCard) Get

func (m *GiftCard) Get(context fiber.Ctx) error

@oas:path [get] /admin/gift-cards/{id} operationId: "GetGiftCardsGiftCard" summary: "Get a Gift Card" description: "Retrieve a Gift Card's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Gift Card.

x-codegen:

method: 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.giftCards.retrieve(giftCardId) .then(({ gift_card }) => { console.log(gift_card.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminGiftCard } from "medusa-react"

    type Props = { giftCardId: string }

    const CustomGiftCard = ({ giftCardId }: Props) => { const { gift_card, isLoading } = useAdminGiftCard(giftCardId)

    return ( <div> {isLoading && <span>Loading...</span>} {gift_card && <span>{gift_card.code}</span>} </div> ) }

    export default CustomGiftCard

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/gift-cards/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Gift Cards

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminGiftCardsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*GiftCard) List

func (m *GiftCard) List(context fiber.Ctx) error

@oas:path [get] /admin/gift-cards operationId: "GetGiftCards" summary: "List Gift Cards" description: "Retrieve a list of Gift Cards. The gift cards can be filtered by fields such as `q`. The gift cards can also paginated." x-authenticated: true parameters:

  • (query) offset=0 {number} The number of gift cards to skip when retrieving the gift cards.
  • (query) limit=50 {number} Limit the number of gift cards returned.
  • (query) q {string} a term to search gift cards' code or display ID

x-codegen:

method: list
queryParams: AdminGetGiftCardsParams

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: tsx label: Medusa React source: | import React from "react" import { GiftCard } from "@medusajs/medusa" import { useAdminGiftCards } from "medusa-react"

    const CustomGiftCards = () => { const { gift_cards, isLoading } = useAdminGiftCards()

    return ( <div> {isLoading && <span>Loading...</span>} {gift_cards && !gift_cards.length && ( <span>No custom gift cards...</span> )} {gift_cards && gift_cards.length > 0 && ( <ul> {gift_cards.map((giftCard: GiftCard) => ( <li key={giftCard.id}>{giftCard.code}</li> ))} </ul> )} </div> ) }

    export default CustomGiftCards

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/gift-cards' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Gift Cards

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminGiftCardsListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*GiftCard) SetRoutes

func (m *GiftCard) SetRoutes(router fiber.Router)

func (*GiftCard) Update

func (m *GiftCard) Update(context fiber.Ctx) error

@oas:path [post] /admin/gift-cards/{id} operationId: "PostGiftCardsGiftCard" summary: "Update a Gift Card" description: "Update a Gift Card's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Gift Card.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostGiftCardsGiftCardReq"

x-codegen:

method: update

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(giftCardId, { region_id }) .then(({ gift_card }) => { console.log(gift_card.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateGiftCard } from "medusa-react"

    type Props = { customGiftCardId: string }

    const CustomGiftCard = ({ customGiftCardId }: Props) => { const updateGiftCard = useAdminUpdateGiftCard( customGiftCardId ) // ...

    const handleUpdate = (regionId: string) => { updateGiftCard.mutate({ region_id: regionId, }, { onSuccess: ({ gift_card }) => { console.log(gift_card.id) } }) }

    // ... }

    export default CustomGiftCard

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/gift-cards/{id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "region_id": "{region_id}" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Gift Cards

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminGiftCardsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type InventoryItem

type InventoryItem struct {
	// contains filtered or unexported fields
}

func NewInventoryItem

func NewInventoryItem(r Registry) *InventoryItem

func (*InventoryItem) Create

func (m *InventoryItem) Create(context fiber.Ctx) error

func (*InventoryItem) CreateLocationLevel

func (m *InventoryItem) CreateLocationLevel(context fiber.Ctx) error

func (*InventoryItem) Delete

func (m *InventoryItem) Delete(context fiber.Ctx) error

func (*InventoryItem) DeleteLocationLevels

func (m *InventoryItem) DeleteLocationLevels(context fiber.Ctx) error

func (*InventoryItem) Get

func (m *InventoryItem) Get(context fiber.Ctx) error

func (*InventoryItem) List

func (m *InventoryItem) List(context fiber.Ctx) error

func (*InventoryItem) ListLocationLevels

func (m *InventoryItem) ListLocationLevels(context fiber.Ctx) error

func (*InventoryItem) SetRoutes

func (m *InventoryItem) SetRoutes(router fiber.Router)

func (*InventoryItem) Update

func (m *InventoryItem) Update(context fiber.Ctx) error

func (*InventoryItem) UpdateLocationLevel

func (m *InventoryItem) UpdateLocationLevel(context fiber.Ctx) error

type Invite

type Invite struct {
	// contains filtered or unexported fields
}

func NewInvite

func NewInvite(r Registry) *Invite

func (*Invite) Accept

func (m *Invite) Accept(context fiber.Ctx) error

@oas:path [post] /admin/invites/accept operationId: "PostInvitesInviteAccept" summary: "Accept an Invite" description: "Accept an Invite. This will also delete the invite and create a new user that can log in and perform admin functionalities. The user will have the email associated with the invite, and the password

provided in the request body."

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostInvitesInviteAcceptReq"

x-codegen:

method: accept

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: tsx label: Medusa React source: | import React from "react" import { useAdminAcceptInvite } from "medusa-react"

    const AcceptInvite = () => { const acceptInvite = useAdminAcceptInvite() // ...

    const handleAccept = ( token: string, firstName: string, lastName: string, password: string ) => { acceptInvite.mutate({ token, user: { first_name: firstName, last_name: lastName, password, }, }, { onSuccess: () => { // invite accepted successfully. } }) }

    // ... }

    export default AcceptInvite

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/invites/accept' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "token": "{token}", "user": { "first_name": "Brigitte", "last_name": "Collier", "password": "supersecret" } }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Invites

responses:

200:
  description: "OK"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Invite) Create

func (m *Invite) Create(context fiber.Ctx) error

@oas:path [post] /admin/invites operationId: "PostInvites" summary: "Create an Invite" description: "Create an Invite. This will generate a token associated with the invite and trigger an `invite.created` event. If you have a Notification Provider installed that handles this

event, a notification should be sent to the email associated with the invite to allow them to accept the invite."

x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostInvitesReq"

x-codegen:

method: 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.invites.create({ user: "[email protected]", role: "admin" }) .then(() => { // successful }) .catch(() => { // an error occurred })
  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/invites' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "user": "[email protected]", "role": "admin" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Invites

responses:

200:
  description: "OK"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Invite) Delete

func (m *Invite) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/invites/{invite_id} operationId: "DeleteInvitesInvite" summary: "Delete an Invite" description: "Delete an Invite. Only invites that weren't accepted can be deleted." x-authenticated: true parameters:

  • (path) invite_id=* {string} The ID of the Invite

x-codegen:

method: 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.invites.delete(inviteId) .then(({ id, object, deleted }) => { console.log(id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteInvite } from "medusa-react"

    type Props = { inviteId: string }

    const DeleteInvite = ({ inviteId }: Props) => { const deleteInvite = useAdminDeleteInvite(inviteId) // ...

    const handleDelete = () => { deleteInvite.mutate(void 0, { onSuccess: ({ id, object, deleted }) => { console.log(id) } }) }

    // ... }

    export default Invite

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/invites/{invite_id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Invites

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminInviteDeleteRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Invite) List

func (m *Invite) List(context fiber.Ctx) error

@oas:path [get] /admin/invites operationId: "GetInvites" summary: "Lists Invites" description: "Retrieve a list of invites." x-authenticated: true x-codegen:

method: list

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 '"{backend_url}"/admin/invites' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Invites

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminListInvitesRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Invite) Resend

func (m *Invite) Resend(context fiber.Ctx) error

@oas:path [post] /admin/invites/{invite_id}/resend operationId: "PostInvitesInviteResend" summary: "Resend an Invite" description: "Resend an Invite. This renews the expiry date by 7 days and generates a new token for the invite. It also triggers the `invite.created` event, so if you have a Notification Provider installed that handles this

event, a notification should be sent to the email associated with the invite to allow them to accept the invite."

x-authenticated: true parameters:

  • (path) invite_id=* {string} The ID of the Invite

x-codegen:

method: resend

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(inviteId) .then(() => { // successful }) .catch(() => { // an error occurred })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminResendInvite } from "medusa-react"

    type Props = { inviteId: string }

    const ResendInvite = ({ inviteId }: Props) => { const resendInvite = useAdminResendInvite(inviteId) // ...

    const handleResend = () => { resendInvite.mutate(void 0, { onSuccess: () => { // invite resent successfully } }) }

    // ... }

    export default ResendInvite

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/invites/{invite_id}/resend' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Invites

responses:

200:
  description: "OK"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Invite) SetRoutes

func (m *Invite) SetRoutes(router fiber.Router)

func (*Invite) UnauthenticatedInviteRoutes

func (m *Invite) UnauthenticatedInviteRoutes(router fiber.Router)

type Note

type Note struct {
	// contains filtered or unexported fields
}

func NewNote

func NewNote(r Registry) *Note

func (*Note) Create

func (m *Note) Create(context fiber.Ctx) error

@oas:path [post] /admin/notes operationId: "PostNotes" summary: "Create a Note" description: "Create a Note which can be associated with any resource." x-authenticated: true requestBody: content:

application/json:
  schema:
    $ref: "#/components/schemas/AdminPostNotesReq"

x-codegen:

method: 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: tsx label: Medusa React source: | import React from "react" import { useAdminCreateNote } from "medusa-react"

    const CreateNote = () => { const createNote = useAdminCreateNote() // ...

    const handleCreate = () => { createNote.mutate({ resource_id: "order_123", resource_type: "order", value: "We delivered this order" }, { onSuccess: ({ note }) => { console.log(note.id) } }) }

    // ... }

    export default CreateNote

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/notes' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "resource_id": "{resource_id}", "resource_type": "order", "value": "We delivered this order" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Notes

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminNotesRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Note) Delete

func (m *Note) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/notes/{id} operationId: "DeleteNotesNote" summary: "Delete a Note" description: "Delete a Note." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Note to delete.

x-codegen:

method: 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(noteId) .then(({ id, object, deleted }) => { console.log(id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteNote } from "medusa-react"

    type Props = { noteId: string }

    const Note = ({ noteId }: Props) => { const deleteNote = useAdminDeleteNote(noteId) // ...

    const handleDelete = () => { deleteNote.mutate() }

    // ... }

    export default Note

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/notes/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Notes

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminNotesDeleteRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Note) Get

func (m *Note) Get(context fiber.Ctx) error

@oas:path [get] /admin/notes/{id} operationId: "GetNotesNote" summary: "Get a Note" description: "Retrieve a note's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the note.

x-codegen:

method: 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(noteId) .then(({ note }) => { console.log(note.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminNote } from "medusa-react"

    type Props = { noteId: string }

    const Note = ({ noteId }: Props) => { const { note, isLoading } = useAdminNote(noteId)

    return ( <div> {isLoading && <span>Loading...</span>} {note && <span>{note.resource_type}</span>} </div> ) }

    export default Note

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/notes/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Notes

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminNotesRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Note) List

func (m *Note) List(context fiber.Ctx) error

@oas:path [get] /admin/notes operationId: "GetNotes" summary: "List Notes" x-authenticated: true description: "Retrieve a list of notes. The notes can be filtered by fields such as `resource_id`. The notes can also be paginated." parameters:

  • (query) limit=50 {number} Limit the number of notes returned.
  • (query) offset=0 {number} The number of notes to skip when retrieving the notes.
  • (query) resource_id {string} Filter by resource ID

x-codegen:

method: list
queryParams: AdminGetNotesParams

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: tsx label: Medusa React source: | import React from "react" import { useAdminNotes } from "medusa-react"

    const Notes = () => { const { notes, isLoading } = useAdminNotes()

    return ( <div> {isLoading && <span>Loading...</span>} {notes && !notes.length && <span>No Notes</span>} {notes && notes.length > 0 && ( <ul> {notes.map((note) => ( <li key={note.id}>{note.resource_type}</li> ))} </ul> )} </div> ) }

    export default Notes

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/notes' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Notes

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminNotesListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Note) SetRoutes

func (m *Note) SetRoutes(router fiber.Router)

func (*Note) Update

func (m *Note) Update(context fiber.Ctx) error

@oas:path [post] /admin/notes/{id} operationId: "PostNotesNote" summary: "Update a Note" x-authenticated: true description: "Update a Note's details." parameters:

  • (path) id=* {string} The ID of the Note

requestBody: content:

application/json:
  schema:
    $ref: "#/components/schemas/AdminPostNotesNoteReq"

x-codegen:

method: update

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(noteId, { value: "We delivered this order" }) .then(({ note }) => { console.log(note.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateNote } from "medusa-react"

    type Props = { noteId: string }

    const Note = ({ noteId }: Props) => { const updateNote = useAdminUpdateNote(noteId) // ...

    const handleUpdate = ( value: string ) => { updateNote.mutate({ value }, { onSuccess: ({ note }) => { console.log(note.value) } }) }

    // ... }

    export default Note

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/notes/{id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "value": "We delivered this order" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Notes

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminNotesRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type Notification

type Notification struct {
	// contains filtered or unexported fields
}

func NewNotification

func NewNotification(r Registry) *Notification

func (*Notification) List

func (m *Notification) List(context fiber.Ctx) error

@oas:path [get] /admin/notifications operationId: "GetNotifications" summary: "List Notifications" description: "Retrieve a list of notifications. The notifications can be filtered by fields such as `event_name` or `resource_type`. The notifications can also be paginated." x-authenticated: true parameters:

  • (query) offset=0 {integer} The number of inventory items to skip when retrieving the inventory items.
  • (query) limit=50 {integer} Limit the number of notifications returned.
  • (query) fields {string} Comma-separated fields that should be included in each returned notification.
  • (query) expand {string} Comma-separated relations that should be expanded in each returned notification.
  • (query) event_name {string} Filter by the name of the event that triggered sending this notification.
  • (query) resource_type {string} Filter by the resource type.
  • (query) resource_id {string} Filter by the resource ID.
  • (query) to {string} Filter by the address that the Notification was sent to. This will usually be an email address, but it can also 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-codegen:

method: list
queryParams: AdminGetNotificationsParams

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: tsx label: Medusa React source: | import React from "react" import { useAdminNotifications } from "medusa-react"

    const Notifications = () => { const { notifications, isLoading } = useAdminNotifications()

    return ( <div> {isLoading && <span>Loading...</span>} {notifications && !notifications.length && ( <span>No Notifications</span> )} {notifications && notifications.length > 0 && ( <ul> {notifications.map((notification) => ( <li key={notification.id}>{notification.to}</li> ))} </ul> )} </div> ) }

    export default Notifications

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/notifications' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Notifications

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminNotificationsListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Notification) Resend

func (m *Notification) Resend(context fiber.Ctx) error

@oas:path [post] /admin/notifications/{id}/resend operationId: "PostNotificationsNotificationResend" summary: "Resend Notification" description: "Resend a previously sent notifications, with the same data but optionally to a different address." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Notification

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostNotificationsNotificationResendReq"

x-codegen:

method: resend

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(notificationId) .then(({ notification }) => { console.log(notification.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminResendNotification } from "medusa-react"

    type Props = { notificationId: string }

    const Notification = ({ notificationId }: Props) => { const resendNotification = useAdminResendNotification( notificationId ) // ...

    const handleResend = () => { resendNotification.mutate({}, { onSuccess: ({ notification }) => { console.log(notification.id) } }) }

    // ... }

    export default Notification

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/notifications/{id}/resend' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Notifications

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminNotificationsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Notification) SetRoutes

func (m *Notification) SetRoutes(router fiber.Router)

type Order

type Order struct {
	// contains filtered or unexported fields
}

func NewOrder

func NewOrder(r Registry) *Order

func (*Order) AddShippingMethod

func (m *Order) AddShippingMethod(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id}/shipping-methods operationId: "PostOrdersOrderShippingMethods" summary: "Add a Shipping Method" description: "Add a Shipping Method to an Order. If another Shipping Method exists with the same Shipping Profile, the previous Shipping Method will be replaced." parameters:

  • (path) id=* {string} The ID of the Order.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostOrdersOrderShippingMethodsReq"

x-authenticated: true x-codegen:

method: addShippingMethod
params: AdminPostOrdersOrderShippingMethodsParams

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(orderId, { price: 1000, option_id }) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminAddShippingMethod } from "medusa-react"

    type Props = { orderId: string }

    const Order = ({ orderId }: Props) => { const addShippingMethod = useAdminAddShippingMethod( orderId ) // ...

    const handleAddShippingMethod = ( optionId: string, price: number ) => { addShippingMethod.mutate({ option_id: optionId, price }, { onSuccess: ({ order }) => { console.log(order.shipping_methods) } }) }

    // ... }

    export default Order

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/{id}/shipping-methods' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "price": 1000, "option_id": "{option_id}" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) Archive

func (m *Order) Archive(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id}/archive operationId: "PostOrdersOrderArchive" summary: "Archive Order" description: "Archive an order and change its status." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Order.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

x-codegen:

method: archive
params: AdminPostOrdersOrderArchiveParams

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(orderId) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminArchiveOrder } from "medusa-react"

    type Props = { orderId: string }

    const Order = ({ orderId }: Props) => { const archiveOrder = useAdminArchiveOrder( orderId ) // ...

    const handleArchivingOrder = () => { archiveOrder.mutate(void 0, { onSuccess: ({ order }) => { console.log(order.status) } }) }

    // ... }

    export default Order

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/{id}/archive' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) Cancel

func (m *Order) Cancel(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id}/cancel operationId: "PostOrdersOrderCancel" summary: "Cancel an Order" description: "Cancel an order and change its status. This will also cancel any associated Fulfillments and Payments, and it may fail if the Payment or Fulfillment Provider is unable to cancel the Payment/Fulfillment." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Order.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

x-codegen:

method: cancel
params: AdminPostOrdersOrderCancel

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(orderId) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCancelOrder } from "medusa-react"

    type Props = { orderId: string }

    const Order = ({ orderId }: Props) => { const cancelOrder = useAdminCancelOrder( orderId ) // ...

    const handleCancel = () => { cancelOrder.mutate(void 0, { onSuccess: ({ order }) => { console.log(order.status) } }) }

    // ... }

    export default Order

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/{id}/cancel' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) CancelClaim

func (m *Order) CancelClaim(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id}/claims/{claim_id}/cancel operationId: "PostOrdersClaimCancel" summary: "Cancel a Claim" description: "Cancel a Claim and change its status. A claim can't be canceled if it has a refund, if its fulfillments haven't been canceled, of if its associated return hasn't been canceled." x-authenticated: true externalDocs:

description: Canceling a claim
url: https://docs.medusajs.com/modules/orders/claims#cancel-a-claim

parameters:

  • (path) id=* {string} The ID of the order the claim is associated with.
  • (path) claim_id=* {string} The ID of the Claim.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

x-codegen:

method: cancelClaim
params: AdminPostOrdersClaimCancel

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(orderId, claimId) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCancelClaim } from "medusa-react"

    type Props = { orderId: string claimId: string }

    const Claim = ({ orderId, claimId }: Props) => { const cancelClaim = useAdminCancelClaim(orderId) // ...

    const handleCancel = () => { cancelClaim.mutate(claimId) }

    // ... }

    export default Claim

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/{id}/claims/{claim_id}/cancel' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) CancelFullfillment

func (m *Order) CancelFullfillment(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id}/fulfillments/{fulfillment_id}/cancel operationId: "PostOrdersOrderFulfillmentsCancel" summary: "Cancel a Fulfilmment" description: "Cancel an order's fulfillment and change its fulfillment status to `canceled`." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Order.
  • (path) fulfillment_id=* {string} The ID of the Fulfillment.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

x-codegen:

method: cancelFulfillment
params: AdminPostOrdersOrderFulfillementsCancelParams

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(orderId, fulfillmentId) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCancelFulfillment } from "medusa-react"

    type Props = { orderId: string }

    const Order = ({ orderId }: Props) => { const cancelFulfillment = useAdminCancelFulfillment( orderId ) // ...

    const handleCancel = ( fulfillmentId: string ) => { cancelFulfillment.mutate(fulfillmentId, { onSuccess: ({ order }) => { console.log(order.fulfillments) } }) }

    // ... }

    export default Order

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/{id}/fulfillments/{fulfillment_id}/cancel' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) CancelFullfillmentClaim

func (m *Order) CancelFullfillmentClaim(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id}/claims/{claim_id}/fulfillments/{fulfillment_id}/cancel operationId: "PostOrdersClaimFulfillmentsCancel" summary: "Cancel Claim's Fulfillment" description: "Cancel a claim's fulfillment and change its fulfillment status to `canceled`." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the order the claim is associated with.
  • (path) claim_id=* {string} The ID of the claim.
  • (path) fulfillment_id=* {string} The ID of the fulfillment.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

x-codegen:

method: cancelClaimFulfillment
params: AdminPostOrdersClaimFulfillmentsCancelParams

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(orderId, claimId, fulfillmentId) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCancelClaimFulfillment } from "medusa-react"

    type Props = { orderId: string claimId: string }

    const Claim = ({ orderId, claimId }: Props) => { const cancelFulfillment = useAdminCancelClaimFulfillment( orderId ) // ...

    const handleCancel = (fulfillmentId: string) => { cancelFulfillment.mutate({ claim_id: claimId, fulfillment_id: fulfillmentId, }, { onSuccess: ({ order }) => { console.log(order.claims) } }) }

    // ... }

    export default Claim

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/{id}/claims/{claim_id}/fulfillments/{fulfillment_id}/cancel' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) CancelFullfillmentSwap

func (m *Order) CancelFullfillmentSwap(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id}/swaps/{swap_id}/fulfillments/{fulfillment_id}/cancel operationId: "PostOrdersSwapFulfillmentsCancel" summary: "Cancel Swap's Fulfilmment" description: "Cancel a swap's fulfillment and change its fulfillment status to `canceled`." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the order the swap is associated with.
  • (path) swap_id=* {string} The ID of the swap.
  • (path) fulfillment_id=* {string} The ID of the fulfillment.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

x-codegen:

method: cancelSwapFulfillment
params: AdminPostOrdersSwapFulfillementsCancelParams

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(orderId, swapId, fulfillmentId) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCancelSwapFulfillment } from "medusa-react"

    type Props = { orderId: string, swapId: string }

    const Swap = ({ orderId, swapId }: Props) => { const cancelFulfillment = useAdminCancelSwapFulfillment( orderId ) // ...

    const handleCancelFulfillment = ( fulfillmentId: string ) => { cancelFulfillment.mutate({ swap_id: swapId, fulfillment_id: fulfillmentId, }) }

    // ... }

    export default Swap

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/{id}/swaps/{swap_id}/fulfillments/{fulfillment_id}/cancel' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) CancelSwap

func (m *Order) CancelSwap(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id}/swaps/{swap_id}/cancel operationId: "PostOrdersSwapCancel" summary: "Cancel a Swap" description: "Cancel a Swap and change its status." x-authenticated: true externalDocs:

description: Canceling a swap
url: https://docs.medusajs.com/modules/orders/swaps#canceling-a-swap

parameters:

  • (path) id=* {string} The ID of the Order the swap is associated with.
  • (path) swap_id=* {string} The ID of the Swap.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

x-codegen:

method: cancelSwap
params: AdminPostOrdersSwapCancelParams

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(orderId, swapId) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCancelSwap } from "medusa-react"

    type Props = { orderId: string, swapId: string }

    const Swap = ({ orderId, swapId }: Props) => { const cancelSwap = useAdminCancelSwap( orderId ) // ...

    const handleCancel = () => { cancelSwap.mutate(swapId, { onSuccess: ({ order }) => { console.log(order.swaps) } }) }

    // ... }

    export default Swap

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/{order_id}/swaps/{swap_id}/cancel' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) CapturePayment

func (m *Order) CapturePayment(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id}/capture operationId: "PostOrdersOrderCapture" summary: "Capture an Order's Payments" description: "Capture all the Payments associated with an Order. The payment of canceled orders can't be captured." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Order.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

x-codegen:

method: capturePayment
params: AdminPostOrdersOrderCaptureParams

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(orderId) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCapturePayment } from "medusa-react"

    type Props = { orderId: string }

    const Order = ({ orderId }: Props) => { const capturePayment = useAdminCapturePayment( orderId ) // ...

    const handleCapture = () => { capturePayment.mutate(void 0, { onSuccess: ({ order }) => { console.log(order.status) } }) }

    // ... }

    export default Order

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/{id}/capture' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) Complete

func (m *Order) Complete(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id}/complete operationId: "PostOrdersOrderComplete" summary: "Complete an Order" description: "Complete an Order and change its status. A canceled order can't be completed." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Order.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

x-codegen:

method: complete
params: AdminPostOrdersOrderCompleteParams

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(orderId) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCompleteOrder } from "medusa-react"

    type Props = { orderId: string }

    const Order = ({ orderId }: Props) => { const completeOrder = useAdminCompleteOrder( orderId ) // ...

    const handleComplete = () => { completeOrder.mutate(void 0, { onSuccess: ({ order }) => { console.log(order.status) } }) }

    // ... }

    export default Order

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/{id}/complete' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) CreateClaim

func (m *Order) CreateClaim(context fiber.Ctx) error
    const CreateClaim = ({ orderId }: Props) => {

    const CreateClaim = (orderId: string) => {
      const createClaim = useAdminCreateClaim(orderId)
      // ...

      const handleCreate = (itemId: string) => {
        createClaim.mutate({
          type: "refund",
          claim_items: [
            {
              item_id: itemId,
              quantity: 1,
            },
          ],
        }, {
          onSuccess: ({ order }) => {
            console.log(order.claims)
          }
        })
      }

      // ...
    }

    export default CreateClaim
- lang: Shell
  label: cURL
  source: |
    curl -X POST '"{backend_url}"/admin/orders/{id}/claims' \
    -H 'x-medusa-access-token: "{api_token}"' \
    -H 'Content-Type: application/json' \
    --data-raw '{
        "type": "refund",
        "claim_items": [
          {
            "item_id": "asdsd",
            "quantity": 1
          }
        ]
    }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) CreateClaimShippment

func (m *Order) CreateClaimShippment(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id}/claims/{claim_id}/shipments operationId: "PostOrdersOrderClaimsClaimShipments" summary: "Ship a Claim's Fulfillment" description: "Create a shipment for the claim and mark its fulfillment as shipped. This changes the claim's fulfillment status to either `partially_shipped` or `shipped`, depending on

whether all the items were shipped."

x-authenticated: true externalDocs:

description: Fulfill a claim
url: https://docs.medusajs.com/modules/orders/claims#fulfill-a-claim

parameters:

  • (path) id=* {string} The ID of the Order the claim is associated with.
  • (path) claim_id=* {string} The ID of the Claim.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostOrdersOrderClaimsClaimShipmentsReq"

x-codegen:

method: createClaimShipment
params: AdminPostOrdersOrderClaimsClaimShipmentsParams

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(orderId, claimId, { fulfillment_id }) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateClaimShipment } from "medusa-react"

    type Props = { orderId: string claimId: string }

    const Claim = ({ orderId, claimId }: Props) => { const createShipment = useAdminCreateClaimShipment(orderId) // ...

    const handleCreateShipment = (fulfillmentId: string) => { createShipment.mutate({ claim_id: claimId, fulfillment_id: fulfillmentId, }, { onSuccess: ({ order }) => { console.log(order.claims) } }) }

    // ... }

    export default Claim

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/{id}/claims/{claim_id}/shipments' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "fulfillment_id": "{fulfillment_id}" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) CreateFulfillment

func (m *Order) CreateFulfillment(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id}/fulfillment operationId: "PostOrdersOrderFulfillments" summary: "Create a Fulfillment" description: "Create a Fulfillment of an Order using the fulfillment provider, and change the order's fulfillment status to either `partially_fulfilled` or `fulfilled`, depending on

whether all the items were fulfilled."

x-authenticated: true externalDocs:

description: Fulfillments of orders
url: https://docs.medusajs.com/modules/orders/#fulfillments-in-orders

parameters:

  • (path) id=* {string} The ID of the Order.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostOrdersOrderFulfillmentsReq"

x-codegen:

method: createFulfillment
params: AdminPostOrdersOrderFulfillmentsParams

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(orderId, { items: [ { item_id, quantity: 1 } ] }) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateFulfillment } from "medusa-react"

    type Props = { orderId: string }

    const Order = ({ orderId }: Props) => { const createFulfillment = useAdminCreateFulfillment( orderId ) // ...

    const handleCreateFulfillment = ( itemId: string, quantity: number ) => { createFulfillment.mutate({ items: [ { item_id: itemId, quantity, }, ], }, { onSuccess: ({ order }) => { console.log(order.fulfillments) } }) }

    // ... }

    export default Order

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/{id}/fulfillment' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "items": [ { "item_id": "{item_id}", "quantity": 1 } ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) CreateReservationForLineItem

func (m *Order) CreateReservationForLineItem(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id}/line-items/{line_item_id}/reserve operationId: "PostOrdersOrderLineItemReservations" summary: "Create a Reservation" description: "Create a Reservation for a line item at a specified location, optionally for a partial quantity." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Order.
  • (path) line_item_id=* {string} The ID of the Line item.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminOrdersOrderLineItemReservationReq"

x-codeSamples:

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/{id}/line-items/{line_item_id}/reserve' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "location_id": "loc_1" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPostReservationsReq"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) CreateShipment

func (m *Order) CreateShipment(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id}/shipment operationId: "PostOrdersOrderShipment" summary: "Ship a Fulfillment" description: "Create a shipment and mark a fulfillment as shipped. This changes the order's fulfillment status to either `partially_shipped` or `shipped`, depending on

whether all the items were shipped."

x-authenticated: true externalDocs:

description: Fulfillments of orders
url: https://docs.medusajs.com/modules/orders/#fulfillments-in-orders

parameters:

  • (path) id=* {string} The ID of the Order.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostOrdersOrderShipmentReq"

x-codegen:

method: createShipment
params: AdminPostOrdersOrderShipmentParams

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: tsx label: Medusa React source: | import React from "react" import { useAdminCreateShipment } from "medusa-react"

    type Props = { orderId: string }

    const Order = ({ orderId }: Props) => { const createShipment = useAdminCreateShipment( orderId ) // ...

    const handleCreate = ( fulfillmentId: string ) => { createShipment.mutate({ fulfillment_id: fulfillmentId, }, { onSuccess: ({ order }) => { console.log(order.fulfillment_status) } }) }

    // ... }

    export default Order

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/{id}/shipment' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "fulfillment_id": "{fulfillment_id}" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) CreateSwap

func (m *Order) CreateSwap(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id}/swaps operationId: "PostOrdersOrderSwaps" summary: "Create a Swap" description: "Create a Swap. This includes creating a return that is associated with the swap." x-authenticated: true externalDocs:

description: How are swaps created
url: https://docs.medusajs.com/modules/orders/swaps#how-are-swaps-created

parameters:

  • (path) id=* {string} The ID of the Order.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostOrdersOrderSwapsReq"

x-codegen:

method: createSwap
queryParams: AdminPostOrdersOrderSwapsParams

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(orderId, { return_items: [ { item_id, quantity: 1 } ] }) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateSwap } from "medusa-react"

    type Props = { orderId: string }

    const CreateSwap = ({ orderId }: Props) => { const createSwap = useAdminCreateSwap(orderId) // ...

    const handleCreate = ( returnItems: { item_id: string, quantity: number }[] ) => { createSwap.mutate({ return_items: returnItems }, { onSuccess: ({ order }) => { console.log(order.swaps) } }) }

    // ... }

    export default CreateSwap

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/{id}/swaps' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "return_items": [ { "item_id": "asfasf", "quantity": 1 } ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) CreateSwapShipment

func (m *Order) CreateSwapShipment(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id}/swaps/{swap_id}/shipments operationId: "PostOrdersOrderSwapsSwapShipments" summary: "Ship a Swap's Fulfillment" description: "Create a shipment for a swap and mark its fulfillment as shipped. This changes the swap's fulfillment status to either `partially_shipped` or `shipped`, depending on

whether all the items were shipped."

x-authenticated: true externalDocs:

description: Handling swap fulfillments
url: https://docs.medusajs.com/modules/orders/swaps#handling-swap-fulfillment

parameters:

  • (path) id=* {string} The ID of the Order.
  • (path) swap_id=* {string} The ID of the Swap.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostOrdersOrderSwapsSwapShipmentsReq"

x-codegen:

method: createSwapShipment
params: AdminPostOrdersOrderSwapsSwapShipmentsParams

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(orderId, swapId, { fulfillment_id }) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateSwapShipment } from "medusa-react"

    type Props = { orderId: string, swapId: string }

    const Swap = ({ orderId, swapId }: Props) => { const createShipment = useAdminCreateSwapShipment( orderId ) // ...

    const handleCreateShipment = ( fulfillmentId: string ) => { createShipment.mutate({ swap_id: swapId, fulfillment_id: fulfillmentId, }, { onSuccess: ({ order }) => { console.log(order.swaps) } }) }

    // ... }

    export default Swap

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/{id}/swaps/{swap_id}/shipments' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "fulfillment_id": "{fulfillment_id}" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) FulfillClaim

func (m *Order) FulfillClaim(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id}/claims/{claim_id}/fulfillments operationId: "PostOrdersOrderClaimsClaimFulfillments" summary: "Create a Claim Fulfillment" description: "Create a Fulfillment for a Claim, and change its fulfillment status to `partially_fulfilled` or `fulfilled` depending on whether all the items were fulfilled. It may also change the status to `requires_action` if any actions are required." x-authenticated: true externalDocs:

description: Fulfill a claim
url: https://docs.medusajs.com/modules/orders/claims#fulfill-a-claim

parameters:

  • (path) id=* {string} The ID of the Order the claim is associated with.
  • (path) claim_id=* {string} The ID of the Claim.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostOrdersOrderClaimsClaimFulfillmentsReq"

x-codegen:

method: fulfillClaim
params: AdminPostOrdersOrderClaimsClaimFulfillmentsReq

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(orderId, claimId, { }) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminFulfillClaim } from "medusa-react"

    type Props = { orderId: string claimId: string }

    const Claim = ({ orderId, claimId }: Props) => { const fulfillClaim = useAdminFulfillClaim(orderId) // ...

    const handleFulfill = () => { fulfillClaim.mutate({ claim_id: claimId, }, { onSuccess: ({ order }) => { console.log(order.claims) } }) }

    // ... }

    export default Claim

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/{id}/claims/{claim_id}/fulfillments' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) FulfillSwap

func (m *Order) FulfillSwap(context fiber.Ctx) error
    medusa.admin.orders.fulfillSwap(orderId, swapId, {

    })
    .then(({ order }) => {
      console.log(order.id);
    })
- lang: tsx
  label: Medusa React
  source: |
    import React from "react"
    import { useAdminFulfillSwap } from "medusa-react"

    type Props = {
      orderId: string,
      swapId: string
    }

    const Swap = ({
      orderId,
      swapId
    }: Props) => {
      const fulfillSwap = useAdminFulfillSwap(
        orderId
      )
      // ...

      const handleFulfill = () => {
        fulfillSwap.mutate({
          swap_id: swapId,
        }, {
          onSuccess: ({ order }) => {
            console.log(order.swaps)
          }
        })
      }

      // ...
    }

    export default Swap
- lang: Shell
  label: cURL
  source: |
    curl -X POST '"{backend_url}"/admin/orders/{id}/swaps/{swap_id}/fulfillments' \
    -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) Get

func (m *Order) Get(context fiber.Ctx) error

@oas:path [get] /admin/orders/{id} operationId: "GetOrdersOrder" summary: "Get an Order" description: "Retrieve an Order's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Order.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

x-codegen:

method: retrieve
queryParams: AdminGetOrdersOrderParams

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(orderId) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminOrder } from "medusa-react"

    type Props = { orderId: string }

    const Order = ({ orderId }: Props) => { const { order, isLoading, } = useAdminOrder(orderId)

    return ( <div> {isLoading && <span>Loading...</span>} {order && <span>{order.display_id}</span>}

    </div> ) }

    export default Order

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/orders/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) GetReservations

func (m *Order) GetReservations(context fiber.Ctx) error

@oas:path [get] /admin/orders/{id}/reservations operationId: "GetOrdersOrderReservations" summary: "Get Order Reservations" description: "Retrieve the list of reservations of an Order" x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Order.
  • (query) offset=0 {integer} The number of reservations to skip when retrieving the reservations.
  • (query) limit=20 {integer} Limit the number of reservations returned.

x-codeSamples:

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/orders/{id}/reservations' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminReservationsListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) List

func (m *Order) List(context fiber.Ctx) error

@oas:path [get] /admin/orders operationId: "GetOrders" summary: "List Orders" description: "Retrieve a list of Orders. The orders can be filtered by fields such as `status` or `display_id`. The order can also be paginated." x-authenticated: true parameters:

  • (query) q {string} term to search orders' shipping address, first name, email, and display ID
  • (query) id {string} Filter by ID.
  • in: query name: status style: form explode: false description: Filter by status schema: type: array items: type: string enum: [pending, completed, archived, canceled, requires_action]
  • in: query name: fulfillment_status style: form explode: false description: Filter by fulfillment status schema: type: array items: type: string enum: [not_fulfilled, fulfilled, partially_fulfilled, shipped, partially_shipped, canceled, returned, partially_returned, requires_action]
  • in: query name: payment_status style: form explode: false description: Filter by payment status schema: type: array items: type: string enum: [captured, awaiting, not_paid, refunded, partially_refunded, canceled, requires_action]
  • (query) display_id {string} Filter by display ID
  • (query) cart_id {string} Filter by cart ID
  • (query) customer_id {string} Filter by customer ID
  • (query) email {string} Filter by email
  • in: query name: region_id style: form explode: false description: Filter by region IDs. schema: oneOf:
  • type: string description: ID of a Region.
  • type: array items: type: string description: ID of a Region.
  • in: query name: currency_code style: form explode: false description: Filter by currency codes. schema: type: string externalDocs: url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes description: See a list of codes.
  • (query) tax_rate {string} Filter by tax rate.
  • in: query name: created_at description: Filter by a creation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: updated_at description: Filter by an update date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: canceled_at description: Filter by a cancelation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: sales_channel_id style: form explode: false description: Filter by Sales Channel IDs schema: type: array items: type: string description: The ID of a Sales Channel
  • (query) offset=0 {integer} The number of orders to skip when retrieving the orders.
  • (query) limit=50 {integer} Limit the number of orders returned.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.
  • (query) order {string} A order field to sort-order the retrieved orders by.

x-codegen:

method: list
queryParams: AdminGetOrdersParams

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: tsx label: Medusa React source: | import React from "react" import { useAdminOrders } from "medusa-react"

    const Orders = () => { const { orders, isLoading } = useAdminOrders()

    return ( <div> {isLoading && <span>Loading...</span>} {orders && !orders.length && <span>No Orders</span>} {orders && orders.length > 0 && ( <ul> {orders.map((order) => ( <li key={order.id}>{order.display_id}</li> ))} </ul> )} </div> ) }

    export default Orders

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/orders' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) ProcessSwapPayment

func (m *Order) ProcessSwapPayment(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id}/swaps/{swap_id}/process-payment operationId: "PostOrdersOrderSwapsSwapProcessPayment" summary: "Process a Swap Payment" description: "Process a swap's payment either by refunding or issuing a payment. This depends on the `difference_due` of the swap. If `difference_due` is negative, the amount is refunded.

If `difference_due` is positive, the amount is captured."

x-authenticated: true externalDocs:

description: Handling a swap's payment
url: https://docs.medusajs.com/modules/orders/swaps#handling-swap-payment

parameters:

  • (path) id=* {string} The ID of the order the swap is associated with.
  • (path) swap_id=* {string} The ID of the swap.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

x-codegen:

method: processSwapPayment
params: AdminPostOrdersOrderSwapsSwapProcessPaymentParams

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(orderId, swapId) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminProcessSwapPayment } from "medusa-react"

    type Props = { orderId: string, swapId: string }

    const Swap = ({ orderId, swapId }: Props) => { const processPayment = useAdminProcessSwapPayment( orderId ) // ...

    const handleProcessPayment = () => { processPayment.mutate(swapId, { onSuccess: ({ order }) => { console.log(order.swaps) } }) }

    // ... }

    export default Swap

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/{id}/swaps/{swap_id}/process-payment' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) RefundPayment

func (m *Order) RefundPayment(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id}/refund operationId: "PostOrdersOrderRefunds" summary: "Create a Refund" description: "Refund an amount for an order. The amount must be less than or equal the `refundable_amount` of the order." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Order.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostOrdersOrderRefundsReq"

x-codegen:

method: refundPayment
params: AdminPostOrdersOrderRefundsParams

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(orderId, { amount: 1000, reason: "Do not like it" }) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminRefundPayment } from "medusa-react"

    type Props = { orderId: string }

    const Order = ({ orderId }: Props) => { const refundPayment = useAdminRefundPayment( orderId ) // ...

    const handleRefund = ( amount: number, reason: string ) => { refundPayment.mutate({ amount, reason, }, { onSuccess: ({ order }) => { console.log(order.refunds) } }) }

    // ... }

    export default Order

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/adasda/refund' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "amount": 1000, "reason": "Do not like it" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) RequestReturn

func (m *Order) RequestReturn(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id}/return operationId: "PostOrdersOrderReturns" summary: "Request a Return" description: "Request and create a Return for items in an order. If the return shipping method is specified, it will be automatically fulfilled." x-authenticated: true externalDocs:

description: Return creation process
url: https://docs.medusajs.com/modules/orders/returns#returns-process

parameters:

  • (path) id=* {string} The ID of the Order.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostOrdersOrderReturnsReq"

x-codegen:

method: requestReturn
params: AdminPostOrdersOrderReturnsParams

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(orderId, { items: [ { item_id, quantity: 1 } ] }) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminRequestReturn } from "medusa-react"

    type Props = { orderId: string }

    const Order = ({ orderId }: Props) => { const requestReturn = useAdminRequestReturn( orderId ) // ...

    const handleRequestingReturn = ( itemId: string, quantity: number ) => { requestReturn.mutate({ items: [ { item_id: itemId, quantity } ] }, { onSuccess: ({ order }) => { console.log(order.returns) } }) }

    // ... }

    export default Order

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/{id}/return' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "items": [ { "item_id": "{item_id}", "quantity": 1 } ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) SetRoutes

func (m *Order) SetRoutes(router fiber.Router)

func (*Order) Update

func (m *Order) Update(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id} operationId: "PostOrdersOrder" summary: "Update an Order" description: "Update and order's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Order.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostOrdersOrderReq"

x-codegen:

method: update
params: AdminPostOrdersOrderParams

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(orderId, { email: "[email protected]" }) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateOrder } from "medusa-react"

    type Props = { orderId: string }

    const Order = ({ orderId }: Props) => { const updateOrder = useAdminUpdateOrder( orderId )

    const handleUpdate = ( email: string ) => { updateOrder.mutate({ email, }, { onSuccess: ({ order }) => { console.log(order.email) } }) }

    // ... }

    export default Order

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/adasda' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "email": "[email protected]" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Order) UpdateClaim

func (m *Order) UpdateClaim(context fiber.Ctx) error

@oas:path [post] /admin/orders/{id}/claims/{claim_id} operationId: "PostOrdersOrderClaimsClaim" summary: "Update a Claim" description: "Update a Claim's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Order associated with the claim.
  • (path) claim_id=* {string} The ID of the Claim.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned order.
  • (query) fields {string} Comma-separated fields that should be included in the returned order.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostOrdersOrderClaimsClaimReq"

x-codegen:

method: updateClaim
params: AdminPostOrdersOrderClaimsClaimParams

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(orderId, claimId, { no_notification: true }) .then(({ order }) => { console.log(order.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateClaim } from "medusa-react"

    type Props = { orderId: string claimId: string }

    const Claim = ({ orderId, claimId }: Props) => { const updateClaim = useAdminUpdateClaim(orderId) // ...

    const handleUpdate = () => { updateClaim.mutate({ claim_id: claimId, no_notification: false }, { onSuccess: ({ order }) => { console.log(order.claims) } }) }

    // ... }

    export default Claim

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/orders/{id}/claims/{claim_id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "no_notification": true }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Orders

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrdersRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type OrderEdit

type OrderEdit struct {
	// contains filtered or unexported fields
}

func NewOrderEdit

func NewOrderEdit(r Registry) *OrderEdit

func (*OrderEdit) AddLineItem

func (m *OrderEdit) AddLineItem(context fiber.Ctx) error

@oas:path [post] /admin/order-edits/{id}/items operationId: "PostOrderEditsEditLineItems" summary: "Add a Line Item" description: "Create a line item change in the order edit that indicates adding an item in the original order. The item will not be added to the original order until the order edit is

confirmed."

parameters:

  • (path) id=* {string} The ID of the Order Edit.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostOrderEditsEditLineItemsReq"

x-authenticated: true x-codegen:

method: addLineItem

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.orderEdits.addLineItem(orderEditId, { variant_id, quantity }) .then(({ order_edit }) => { console.log(order_edit.id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminOrderEditAddLineItem } from "medusa-react"

    type Props = { orderEditId: string }

    const OrderEdit = ({ orderEditId }: Props) => { const addLineItem = useAdminOrderEditAddLineItem( orderEditId )

    const handleAddLineItem = (quantity: number, variantId: string) => { addLineItem.mutate({ quantity, variant_id: variantId, }, { onSuccess: ({ order_edit }) => { console.log(order_edit.changes) } }) }

    // ... }

    export default OrderEdit

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/order-edits/{id}/items' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "variant_id": "variant_01G1G5V2MRX2V3PVSR2WXYPFB6", "quantity": 3 }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Order Edits

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrderEditsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*OrderEdit) Cancel

func (m *OrderEdit) Cancel(context fiber.Ctx) error

@oas:path [post] /admin/order-edits/{id}/cancel operationId: "PostOrderEditsOrderEditCancel" summary: "Cancel an Order Edit" description: "Cancel an Order Edit." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the OrderEdit.

x-codegen:

method: cancel

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.orderEdits.cancel(orderEditId) .then(({ order_edit }) => { console.log(order_edit.id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCancelOrderEdit } from "medusa-react"

    type Props = { orderEditId: string }

    const OrderEdit = ({ orderEditId }: Props) => { const cancelOrderEdit = useAdminCancelOrderEdit( orderEditId )

    const handleCancel = () => { cancelOrderEdit.mutate(void 0, { onSuccess: ({ order_edit }) => { console.log( order_edit.id ) } }) }

    // ... }

    export default OrderEdit

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/order-edits/{id}/cancel' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Order Edits

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrderEditsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*OrderEdit) Confirm

func (m *OrderEdit) Confirm(context fiber.Ctx) error

@oas:path [post] /admin/order-edits/{id}/confirm operationId: "PostOrderEditsOrderEditConfirm" summary: "Confirm an OrderEdit" description: "Confirm an Order Edit. This will reflect the changes in the order edit on the associated order." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the order edit.

x-codegen:

method: confirm

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.orderEdits.confirm(orderEditId) .then(({ order_edit }) => { console.log(order_edit.id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminConfirmOrderEdit } from "medusa-react"

    type Props = { orderEditId: string }

    const OrderEdit = ({ orderEditId }: Props) => { const confirmOrderEdit = useAdminConfirmOrderEdit( orderEditId )

    const handleConfirmOrderEdit = () => { confirmOrderEdit.mutate(void 0, { onSuccess: ({ order_edit }) => { console.log( order_edit.confirmed_at, order_edit.confirmed_by ) } }) }

    // ... }

    export default OrderEdit

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/order-edits/{id}/confirm' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Order Edits

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrderEditsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*OrderEdit) Create

func (m *OrderEdit) Create(context fiber.Ctx) error

@oas:path [post] /admin/order-edits operationId: "PostOrderEdits" summary: "Create an OrderEdit" description: "Create an Order Edit." requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostOrderEditsReq"

x-authenticated: true x-codegen:

method: 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.orderEdits.create({ orderId }) .then(({ order_edit }) => { console.log(order_edit.id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateOrderEdit } from "medusa-react"

    const CreateOrderEdit = () => { const createOrderEdit = useAdminCreateOrderEdit()

    const handleCreateOrderEdit = (orderId: string) => { createOrderEdit.mutate({ order_id: orderId, }, { onSuccess: ({ order_edit }) => { console.log(order_edit.id) } }) }

    // ... }

    export default CreateOrderEdit

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/order-edits' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "order_id": "my_order_id", "internal_note": "my_optional_note" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Order Edits

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrderEditsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*OrderEdit) Delete

func (m *OrderEdit) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/order-edits/{id} operationId: "DeleteOrderEditsOrderEdit" summary: "Delete an Order Edit" description: "Delete an Order Edit. Only order edits that have the status `created` can be deleted." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Order Edit to delete.

x-codegen:

method: 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.orderEdits.delete(orderEditId) .then(({ id, object, deleted }) => { console.log(id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteOrderEdit } from "medusa-react"

    type Props = { orderEditId: string }

    const OrderEdit = ({ orderEditId }: Props) => { const deleteOrderEdit = useAdminDeleteOrderEdit( orderEditId )

    const handleDelete = () => { deleteOrderEdit.mutate(void 0, { onSuccess: ({ id, object, deleted }) => { console.log(id) } }) }

    // ... }

    export default OrderEdit

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/order-edits/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Order Edits

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrderEditDeleteRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"

func (*OrderEdit) DeleteItemChange

func (m *OrderEdit) DeleteItemChange(context fiber.Ctx) error

@oas:path [delete] /admin/order-edits/{id}/changes/{change_id} operationId: "DeleteOrderEditsOrderEditItemChange" summary: "Delete a Line Item Change" description: "Delete a line item change that indicates the addition, deletion, or update of a line item in the original order." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Order Edit.
  • (path) change_id=* {string} The ID of the Line Item Change to delete.

x-codegen:

method: deleteItemChange

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.orderEdits.deleteItemChange(orderEdit_id, itemChangeId) .then(({ id, object, deleted }) => { console.log(id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteOrderEditItemChange } from "medusa-react"

    type Props = { orderEditId: string itemChangeId: string }

    const OrderEditItemChange = ({ orderEditId, itemChangeId }: Props) => { const deleteItemChange = useAdminDeleteOrderEditItemChange( orderEditId, itemChangeId )

    const handleDeleteItemChange = () => { deleteItemChange.mutate(void 0, { onSuccess: ({ id, object, deleted }) => { console.log(id) } }) }

    // ... }

    export default OrderEditItemChange

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/order-edits/{id}/changes/{change_id}' \ -H 'x-medusa-access-token: "{api_token}"'

security: - api_token: [] - cookie_auth: [] - jwt_token: [] tags: - Order Edits responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrderEditItemChangeDeleteRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"

func (*OrderEdit) DeleteLineItem

func (m *OrderEdit) DeleteLineItem(context fiber.Ctx) error

@oas:path [delete] /admin/order-edits/{id}/items/{item_id} operationId: "DeleteOrderEditsOrderEditLineItemsLineItem" summary: "Delete Line Item" description: "Create a line item change in the order edit that indicates deleting an item in the original order. The item in the original order will not be deleted until the order edit is

confirmed."

x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Order Edit.
  • (path) item_id=* {string} The ID of line item in the original order.

x-codegen:

method: removeLineItem

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.orderEdits.removeLineItem(orderEditId, lineItemId) .then(({ order_edit }) => { console.log(order_edit.id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminOrderEditDeleteLineItem } from "medusa-react"

    type Props = { orderEditId: string itemId: string }

    const OrderEditLineItem = ({ orderEditId, itemId }: Props) => { const removeLineItem = useAdminOrderEditDeleteLineItem( orderEditId, itemId )

    const handleRemoveLineItem = () => { removeLineItem.mutate(void 0, { onSuccess: ({ order_edit }) => { console.log(order_edit.changes) } }) }

    // ... }

    export default OrderEditLineItem

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/order-edits/{id}/items/{item_id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Order Edits

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrderEditsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*OrderEdit) Get

func (m *OrderEdit) Get(context fiber.Ctx) error

@oas:path [get] /admin/order-edits/{id} operationId: "GetOrderEditsOrderEdit" summary: "Get an Order Edit" description: "Retrieve an Order Edit's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the OrderEdit.
  • (query) expand {string} Comma-separated relations that should be expanded in each returned order edit.
  • (query) fields {string} Comma-separated fields that should be included in the returned order edit.

x-codegen:

method: retrieve
queryParams: GetOrderEditsOrderEditParams

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.orderEdits.retrieve(orderEditId) .then(({ order_edit }) => { console.log(order_edit.id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminOrderEdit } from "medusa-react"

    type Props = { orderEditId: string }

    const OrderEdit = ({ orderEditId }: Props) => { const { order_edit, isLoading, } = useAdminOrderEdit(orderEditId)

    return ( <div> {isLoading && <span>Loading...</span>} {order_edit && <span>{order_edit.status}</span>} </div> ) }

    export default OrderEdit

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/order-edits/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Order Edits

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrderEditsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*OrderEdit) List

func (m *OrderEdit) List(context fiber.Ctx) error

@oas:path [get] /admin/order-edits operationId: "GetOrderEdits" summary: "List Order Edits" description: "Retrieve a list of order edits. The order edits can be filtered by fields such as `q` or `order_id`. The order edits can also be paginated." x-authenticated: true parameters:

  • (query) q {string} term to search order edits' internal note.
  • (query) order_id {string} Filter by order ID
  • (query) limit=20 {number} Limit the number of order edits returned.
  • (query) offset=0 {number} The number of order edits to skip when retrieving the order edits.
  • (query) expand {string} Comma-separated relations that should be expanded in each returned order edit.
  • (query) fields {string} Comma-separated fields that should be included in each returned order edit.

x-codegen:

method: list
queryParams: GetOrderEditsParams

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.orderEdits.list() .then(({ order_edits, count, limit, offset }) => { console.log(order_edits.length) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminOrderEdits } from "medusa-react"

    const OrderEdits = () => { const { order_edits, isLoading } = useAdminOrderEdits()

    return ( <div> {isLoading && <span>Loading...</span>} {order_edits && !order_edits.length && ( <span>No Order Edits</span> )} {order_edits && order_edits.length > 0 && ( <ul> {order_edits.map((orderEdit) => ( <li key={orderEdit.id}> {orderEdit.status} </li> ))} </ul> )} </div> ) }

    export default OrderEdits

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/order-edits' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Order Edits

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrderEditsListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*OrderEdit) RequestConfirmation

func (m *OrderEdit) RequestConfirmation(context fiber.Ctx) error

@oas:path [post] /admin/order-edits/{id}/request operationId: "PostOrderEditsOrderEditRequest" summary: "Request Confirmation" description: "Request customer confirmation of an Order Edit. This would emit the event `order-edit.requested` which Notification Providers listen to and send

a notification to the customer about the order edit."

x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Order Edit.

x-codegen:

method: requestConfirmation

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.orderEdits.requestConfirmation(orderEditId) .then({ order_edit }) => { console.log(order_edit.id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminRequestOrderEditConfirmation, } from "medusa-react"

    type Props = { orderEditId: string }

    const OrderEdit = ({ orderEditId }: Props) => { const requestOrderConfirmation = useAdminRequestOrderEditConfirmation( orderEditId )

    const handleRequestConfirmation = () => { requestOrderConfirmation.mutate(void 0, { onSuccess: ({ order_edit }) => { console.log( order_edit.requested_at, order_edit.requested_by ) } }) }

    // ... }

    export default OrderEdit

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/order-edits/{id}/request' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Order Edits

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrderEditsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*OrderEdit) SetRoutes

func (m *OrderEdit) SetRoutes(router fiber.Router)

func (*OrderEdit) Update

func (m *OrderEdit) Update(context fiber.Ctx) error

@oas:path [post] /admin/order-edits/{id} operationId: "PostOrderEditsOrderEdit" summary: "Update an Order Edit" description: "Update an Order Edit's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the OrderEdit.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostOrderEditsOrderEditReq"

x-codegen:

method: update

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.orderEdits.update(orderEditId, { internal_note: "internal reason XY" }) .then(({ order_edit }) => { console.log(order_edit.id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateOrderEdit } from "medusa-react"

    type Props = { orderEditId: string }

    const OrderEdit = ({ orderEditId }: Props) => { const updateOrderEdit = useAdminUpdateOrderEdit( orderEditId, )

    const handleUpdate = ( internalNote: string ) => { updateOrderEdit.mutate({ internal_note: internalNote }, { onSuccess: ({ order_edit }) => { console.log(order_edit.internal_note) } }) }

    // ... }

    export default OrderEdit

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/order-edits/{id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "internal_note": "internal reason XY" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Order Edits

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrderEditsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*OrderEdit) UpdateLineItem

func (m *OrderEdit) UpdateLineItem(context fiber.Ctx) error

@oas:path [post] /admin/order-edits/{id}/items/{item_id} operationId: "PostOrderEditsEditLineItemsLineItem" summary: "Upsert Line Item Change" description: "Create or update a line item change in the order edit that indicates addition, deletion, or update of a line item into an original order. Line item changes are only reflected on the original order after the order edit is confirmed." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Order Edit.
  • (path) item_id=* {string} The ID of the line item in the original order.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostOrderEditsEditLineItemsLineItemReq"

x-codegen:

method: updateLineItem

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.orderEdits.updateLineItem(orderEditId, lineItemId, { quantity: 5 }) .then(({ order_edit }) => { console.log(order_edit.id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminOrderEditUpdateLineItem } from "medusa-react"

    type Props = { orderEditId: string itemId: string }

    const OrderEditItemChange = ({ orderEditId, itemId }: Props) => { const updateLineItem = useAdminOrderEditUpdateLineItem( orderEditId, itemId )

    const handleUpdateLineItem = (quantity: number) => { updateLineItem.mutate({ quantity, }, { onSuccess: ({ order_edit }) => { console.log(order_edit.items) } }) }

    // ... }

    export default OrderEditItemChange

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/order-edits/{id}/items/{item_id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "quantity": 5 }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Order Edits

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminOrderEditsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type Payment

type Payment struct {
	// contains filtered or unexported fields
}

func NewPayment

func NewPayment(r Registry) *Payment

func (*Payment) Capture

func (m *Payment) Capture(context fiber.Ctx) error

@oas:path [post] /admin/payments/{id}/capture operationId: "PostPaymentsPaymentCapture" summary: "Capture a Payment" description: "Capture a Payment." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Payment.

x-codegen:

method: capturePayment

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.payments.capturePayment(paymentId) .then(({ payment }) => { console.log(payment.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminPaymentsCapturePayment } from "medusa-react"

    type Props = { paymentId: string }

    const Payment = ({ paymentId }: Props) => { const capture = useAdminPaymentsCapturePayment( paymentId ) // ...

    const handleCapture = () => { capture.mutate(void 0, { onSuccess: ({ payment }) => { console.log(payment.amount) } }) }

    // ... }

    export default Payment

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/payments/{id}/capture' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Payments

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPaymentRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Payment) Get

func (m *Payment) Get(context fiber.Ctx) error

@oas:path [get] /admin/payments/{id} operationId: "GetPaymentsPayment" summary: "Get Payment details" description: "Retrieve a Payment's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Payment.

x-codegen:

method: retrieve
queryParams: GetPaymentsParams

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.payments.retrieve(paymentId) .then(({ payment }) => { console.log(payment.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminPayment } from "medusa-react"

    type Props = { paymentId: string }

    const Payment = ({ paymentId }: Props) => { const { payment, isLoading, } = useAdminPayment(paymentId)

    return ( <div> {isLoading && <span>Loading...</span>} {payment && <span>{payment.amount}</span>}

    </div> ) }

    export default Payment

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/payments/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Payments

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPaymentRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Payment) Refund

func (m *Payment) Refund(context fiber.Ctx) error

@oas:path [post] /admin/payments/{id}/refund operationId: "PostPaymentsPaymentRefunds" summary: "Refund Payment" description: "Refund a payment. The payment must be captured first." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Payment.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostPaymentRefundsReq"

x-codegen:

method: refundPayment

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.payments.refundPayment(paymentId, { amount: 1000, reason: "return", note: "Do not like it", }) .then(({ payment }) => { console.log(payment.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { RefundReason } from "@medusajs/medusa" import { useAdminPaymentsRefundPayment } from "medusa-react"

    type Props = { paymentId: string }

    const Payment = ({ paymentId }: Props) => { const refund = useAdminPaymentsRefundPayment( paymentId ) // ...

    const handleRefund = ( amount: number, reason: RefundReason, note: string ) => { refund.mutate({ amount, reason, note }, { onSuccess: ({ refund }) => { console.log(refund.amount) } }) }

    // ... }

    export default Payment

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/payments/pay_123/refund' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "amount": 1000, "reason": "return", "note": "Do not like it" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Payments

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminRefundRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Payment) SetRoutes

func (m *Payment) SetRoutes(router fiber.Router)

type PaymentCollection

type PaymentCollection struct {
	// contains filtered or unexported fields
}

func NewPaymentCollection

func NewPaymentCollection(r Registry) *PaymentCollection

func (*PaymentCollection) Delete

func (m *PaymentCollection) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/payment-collections/{id} operationId: "DeletePaymentCollectionsPaymentCollection" summary: "Delete a Payment Collection" description: "Delete a Payment Collection. Only payment collections with the statuses `canceled` or `not_paid` can be deleted." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Payment Collection.

x-codegen:

method: 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.paymentCollections.delete(paymentCollectionId) .then(({ id, object, deleted }) => { console.log(id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeletePaymentCollection } from "medusa-react"

    type Props = { paymentCollectionId: string }

    const PaymentCollection = ({ paymentCollectionId }: Props) => { const deleteCollection = useAdminDeletePaymentCollection( paymentCollectionId ) // ...

    const handleDelete = () => { deleteCollection.mutate(void 0, { onSuccess: ({ id, object, deleted }) => { console.log(id) } }) }

    // ... }

    export default PaymentCollection

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/payment-collections/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Payment Collections

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPaymentCollectionDeleteRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"

func (*PaymentCollection) Get

func (m *PaymentCollection) Get(context fiber.Ctx) error

@oas:path [get] /admin/payment-collections/{id} operationId: "GetPaymentCollectionsPaymentCollection" summary: "Get a Payment Collection" description: "Retrieve a Payment Collection's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Payment Collection.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned payment collection.
  • (query) fields {string} Comma-separated fields that should be included in the returned payment collection.

x-codegen:

method: retrieve
queryParams: AdminGetPaymentCollectionsParams

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.paymentCollections.retrieve(paymentCollectionId) .then(({ payment_collection }) => { console.log(payment_collection.id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminPaymentCollection } from "medusa-react"

    type Props = { paymentCollectionId: string }

    const PaymentCollection = ({ paymentCollectionId }: Props) => { const { payment_collection, isLoading, } = useAdminPaymentCollection(paymentCollectionId)

    return ( <div> {isLoading && <span>Loading...</span>} {payment_collection && ( <span>{payment_collection.status}</span> )}

    </div> ) }

    export default PaymentCollection

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/payment-collections/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Payment Collections

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPaymentCollectionsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*PaymentCollection) MarkAuthorized

func (m *PaymentCollection) MarkAuthorized(context fiber.Ctx) error

@oas:path [post] /admin/payment-collections/{id}/authorize operationId: "PostPaymentCollectionsPaymentCollectionAuthorize" summary: "Mark Authorized" description: "Set the status of a Payment Collection as `authorized`. This will also change the `authorized_amount` of the payment collection." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Payment Collection.

x-codegen:

method: markAsAuthorized

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.paymentCollections.markAsAuthorized(paymentCollectionId) .then(({ payment_collection }) => { console.log(payment_collection.id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminMarkPaymentCollectionAsAuthorized } from "medusa-react"

    type Props = { paymentCollectionId: string }

    const PaymentCollection = ({ paymentCollectionId }: Props) => { const markAsAuthorized = useAdminMarkPaymentCollectionAsAuthorized( paymentCollectionId ) // ...

    const handleAuthorization = () => { markAsAuthorized.mutate(void 0, { onSuccess: ({ payment_collection }) => { console.log(payment_collection.status) } }) }

    // ... }

    export default PaymentCollection

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/payment-collections/{id}/authorize' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Payment Collections

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPaymentCollectionsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*PaymentCollection) SetRoutes

func (m *PaymentCollection) SetRoutes(router fiber.Router)

func (*PaymentCollection) Update

func (m *PaymentCollection) Update(context fiber.Ctx) error

@oas:path [post] /admin/payment-collections/{id} operationId: "PostPaymentCollectionsPaymentCollection" summary: "Update Payment Collection" description: "Update a Payment Collection's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Payment Collection.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminUpdatePaymentCollectionsReq"

x-codegen:

method: update

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.paymentCollections.update(paymentCollectionId, { description }) .then(({ payment_collection }) => { console.log(payment_collection.id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdatePaymentCollection } from "medusa-react"

    type Props = { paymentCollectionId: string }

    const PaymentCollection = ({ paymentCollectionId }: Props) => { const updateCollection = useAdminUpdatePaymentCollection( paymentCollectionId ) // ...

    const handleUpdate = ( description: string ) => { updateCollection.mutate({ description }, { onSuccess: ({ payment_collection }) => { console.log(payment_collection.description) } }) }

    // ... }

    export default PaymentCollection

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/payment-collections/{id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "description": "Description of payment collection" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Payment Collections

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPaymentCollectionsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type PriceList

type PriceList struct {
	// contains filtered or unexported fields
}

func NewPriceList

func NewPriceList(r Registry) *PriceList

func (*PriceList) AddPricesBatch

func (m *PriceList) AddPricesBatch(context fiber.Ctx) error

@oas:path [post] /admin/price-lists/{id}/prices/batch operationId: "PostPriceListsPriceListPricesBatch" summary: "Add or Update Prices" description: "Add or update a list of prices in a Price List." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Price List.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostPriceListPricesPricesReq"

x-codegen:

method: addPrices

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(priceListId, { prices: [ { amount: 1000, variant_id, currency_code: "eur" } ] }) .then(({ price_list }) => { console.log(price_list.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreatePriceListPrices } from "medusa-react"

    type PriceData = { amount: number variant_id: string currency_code: string }

    type Props = { priceListId: string }

    const PriceList = ({ priceListId }: Props) => { const addPrices = useAdminCreatePriceListPrices(priceListId) // ...

    const handleAddPrices = (prices: PriceData[]) => { addPrices.mutate({ prices }, { onSuccess: ({ price_list }) => { console.log(price_list.prices) } }) }

    // ... }

    export default PriceList

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/price-lists/{id}/prices/batch' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "prices": [ { "amount": 100, "variant_id": "afasfa", "currency_code": "eur" } ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Price Lists

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPriceListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*PriceList) Create

func (m *PriceList) Create(context fiber.Ctx) error

@oas:path [post] /admin/price-lists operationId: "PostPriceListsPriceList" summary: "Create a Price List" description: "Create a Price List." x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostPriceListsPriceListReq"

x-codegen:

method: create

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: tsx label: Medusa React source: | import React from "react" import { PriceListStatus, PriceListType, } from "@medusajs/medusa" import { useAdminCreatePriceList } from "medusa-react"

    type CreateData = { name: string description: string type: PriceListType status: PriceListStatus prices: { amount: number variant_id: string currency_code: string max_quantity: number }[] }

    const CreatePriceList = () => { const createPriceList = useAdminCreatePriceList() // ...

    const handleCreate = ( data: CreateData ) => { createPriceList.mutate(data, { onSuccess: ({ price_list }) => { console.log(price_list.id) } }) }

    // ... }

    export default CreatePriceList

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/price-lists' \ -H 'x-medusa-access-token: "{api_token}"' \ -H '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: []
  • jwt_token: []

tags:

  • Price Lists

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPriceListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*PriceList) Delete

func (m *PriceList) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/price-lists/{id} operationId: "DeletePriceListsPriceList" summary: "Delete a Price List" description: "Delete a Price List and its associated prices." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Price List.

x-codegen:

method: 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(priceListId) .then(({ id, object, deleted }) => { console.log(id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeletePriceList } from "medusa-react"

    type Props = { priceListId: string }

    const PriceList = ({ priceListId }: Props) => { const deletePriceList = useAdminDeletePriceList(priceListId) // ...

    const handleDelete = () => { deletePriceList.mutate(void 0, { onSuccess: ({ id, object, deleted }) => { console.log(id) } }) }

    // ... }

    export default PriceList

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/price-lists/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Price Lists

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPriceListDeleteRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*PriceList) DeletePricesBatch

func (m *PriceList) DeletePricesBatch(context fiber.Ctx) error

@oas:path [delete] /admin/price-lists/{id}/prices/batch operationId: "DeletePriceListsPriceListPricesBatch" summary: "Delete Prices" description: "Delete a list of prices in a Price List" x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Price List

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminDeletePriceListPricesPricesReq"

x-codegen:

method: deletePrices

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(priceListId, { price_ids: [ price_id ] }) .then(({ ids, object, deleted }) => { console.log(ids.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeletePriceListPrices } from "medusa-react"

    const PriceList = ( priceListId: string ) => { const deletePrices = useAdminDeletePriceListPrices(priceListId) // ...

    const handleDeletePrices = (priceIds: string[]) => { deletePrices.mutate({ price_ids: priceIds }, { onSuccess: ({ ids, deleted, object }) => { console.log(ids) } }) }

    // ... }

    export default PriceList

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/price-lists/{id}/prices/batch' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "price_ids": [ "adasfa" ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Price Lists

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPriceListDeleteBatchRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*PriceList) DeleteProductPrices

func (m *PriceList) DeleteProductPrices(context fiber.Ctx) error

@oas:path [delete] /admin/price-lists/{id}/products/{product_id}/prices operationId: "DeletePriceListsPriceListProductsProductPrices" summary: "Delete a Product's Prices" description: "Delete all the prices related to a specific product in a price list." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Price List.
  • (path) product_id=* {string} The ID of the product from which the prices will be deleted.

x-codegen:

method: deleteProductPrices

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.deleteProductPrices(priceListId, productId) .then(({ ids, object, deleted }) => { console.log(ids.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeletePriceListProductPrices } from "medusa-react"

    type Props = { priceListId: string productId: string }

    const PriceListProduct = ({ priceListId, productId }: Props) => { const deleteProductPrices = useAdminDeletePriceListProductPrices( priceListId, productId ) // ...

    const handleDeleteProductPrices = () => { deleteProductPrices.mutate(void 0, { onSuccess: ({ ids, deleted, object }) => { console.log(ids) } }) }

    // ... }

    export default PriceListProduct

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/price-lists/{id}/products/{product_id}/prices' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Price Lists

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPriceListDeleteProductPricesRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*PriceList) DeleteProductPricesBatch

func (m *PriceList) DeleteProductPricesBatch(context fiber.Ctx) error

@oas:path [delete] /admin/price-lists/{id}/products/prices/batch operationId: "DeletePriceListsPriceListProductsPricesBatch" summary: "Delete Product Prices" description: "Delete all the prices associated with multiple products in a price list." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Price List

x-codegen:

method: deleteProductsPrices

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.deleteProductsPrices(priceListId, { product_ids: [ productId1, productId2, ] }) .then(({ ids, object, deleted }) => { console.log(ids.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeletePriceListProductsPrices } from "medusa-react"

    type Props = { priceListId: string }

    const PriceList = ({ priceListId }: Props) => { const deleteProductsPrices = useAdminDeletePriceListProductsPrices( priceListId ) // ...

    const handleDeleteProductsPrices = (productIds: string[]) => { deleteProductsPrices.mutate({ product_ids: productIds }, { onSuccess: ({ ids, deleted, object }) => { console.log(ids) } }) }

    // ... }

    export default PriceList

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/price-lists/{id}/products/prices/batch' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "product_ids": [ "prod_1", "prod_2" ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Price Lists

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPriceListDeleteProductPricesRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*PriceList) DeleteVariantPrices

func (m *PriceList) DeleteVariantPrices(context fiber.Ctx) error

@oas:path [delete] /admin/price-lists/{id}/variants/{variant_id}/prices operationId: "DeletePriceListsPriceListVariantsVariantPrices" summary: "Delete a Variant's Prices" description: "Delete all the prices related to a specific variant in a price list." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Price List.
  • (path) variant_id=* {string} The ID of the variant.

x-codegen:

method: deleteVariantPrices

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.deleteVariantPrices(priceListId, variantId) .then(({ ids, object, deleted }) => { console.log(ids); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeletePriceListVariantPrices } from "medusa-react"

    type Props = { priceListId: string variantId: string }

    const PriceListVariant = ({ priceListId, variantId }: Props) => { const deleteVariantPrices = useAdminDeletePriceListVariantPrices( priceListId, variantId ) // ...

    const handleDeleteVariantPrices = () => { deleteVariantPrices.mutate(void 0, { onSuccess: ({ ids, deleted, object }) => { console.log(ids) } }) }

    // ... }

    export default PriceListVariant

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/price-lists/{id}/variants/{variant_id}/prices' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Price Lists

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPriceListDeleteVariantPricesRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*PriceList) Get

func (m *PriceList) Get(context fiber.Ctx) error

@oas:path [get] /admin/price-lists/{id} operationId: "GetPriceListsPriceList" summary: "Get a Price List" description: "Retrieve a Price List's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Price List.

x-codegen:

method: 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.priceLists.retrieve(priceListId) .then(({ price_list }) => { console.log(price_list.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminPriceList } from "medusa-react"

    type Props = { priceListId: string }

    const PriceList = ({ priceListId }: Props) => { const { price_list, isLoading, } = useAdminPriceList(priceListId)

    return ( <div> {isLoading && <span>Loading...</span>} {price_list && <span>{price_list.name}</span>} </div> ) }

    export default PriceList

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/price-lists/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Price Lists

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPriceListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*PriceList) List

func (m *PriceList) List(context fiber.Ctx) error

@oas:path [get] /admin/price-lists operationId: "GetPriceLists" summary: "List Price Lists" description: "Retrieve a list of price lists. The price lists can be filtered by fields such as `q` or `status`. The price lists can also be sorted or paginated." x-authenticated: true parameters:

  • (query) limit=10 {number} Limit the number of price lists returned.
  • (query) offset=0 {number} The number of price lists to skip when retrieving the price lists.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned price lists.
  • (query) fields {string} Comma-separated fields that should be included in the returned price lists.
  • (query) order {string} A price-list field to sort-order the retrieved price lists by.
  • (query) id {string} Filter by ID
  • (query) q {string} term to search price lists' description, name, and customer group's name.
  • in: query name: status style: form explode: false description: Filter by status. schema: type: array items: type: string enum: [active, draft]
  • (query) name {string} Filter by name
  • in: query name: customer_groups style: form explode: false description: Filter by customer-group IDs. schema: type: array items: type: string
  • in: query name: type style: form explode: false description: Filter by type. schema: type: array items: type: string enum: [sale, override]
  • in: query name: created_at description: Filter by a creation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: updated_at description: Filter by an update date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: deleted_at description: Filter by a deletion date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date

x-codegen:

method: list
queryParams: AdminGetPriceListPaginationParams

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.list() .then(({ price_lists, limit, offset, count }) => { console.log(price_lists.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminPriceLists } from "medusa-react"

    const PriceLists = () => { const { price_lists, isLoading } = useAdminPriceLists()

    return ( <div> {isLoading && <span>Loading...</span>} {price_lists && !price_lists.length && ( <span>No Price Lists</span> )} {price_lists && price_lists.length > 0 && ( <ul> {price_lists.map((price_list) => ( <li key={price_list.id}>{price_list.name}</li> ))} </ul> )} </div> ) }

    export default PriceLists

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/price-lists' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Price Lists

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPriceListsListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*PriceList) ListPriceListProducts

func (m *PriceList) ListPriceListProducts(context fiber.Ctx) error

@oas:path [get] /admin/price-lists/{id}/products operationId: "GetPriceListsPriceListProducts" summary: "List Products" description: "Retrieve a price list's products. The products can be filtered by fields such as `q` or `status`. The products can also be sorted or paginated." x-authenticated: true parameters:

  • (path) id=* {string} ID of the price list.
  • (query) q {string} term used to search products' title, description, product variant's title and sku, and product collection's title.
  • (query) id {string} Filter by product ID
  • in: query name: status description: Filter by product status style: form explode: false schema: type: array items: type: string enum: [draft, proposed, published, rejected]
  • in: query name: collection_id description: Filter by product collection ID. Only products in the specified collections are retrieved. style: form explode: false schema: type: array items: type: string
  • in: query name: tags description: Filter by tag IDs. Only products having the specified tags are retrieved. style: form explode: false schema: type: array items: type: string
  • (query) title {string} Filter by title
  • (query) description {string} Filter by description
  • (query) handle {string} Filter by handle
  • (query) is_giftcard {string} A boolean value to filter by whether the product is a gift card or not.
  • (query) type {string} Filter product type.
  • (query) order {string} A product field to sort-order the retrieved products by.
  • in: query name: created_at description: Filter by a creation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: updated_at description: Filter by an update date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: deleted_at description: Filter by a deletion date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • (query) offset=0 {integer} The number of products to skip when retrieving the products.
  • (query) limit=50 {integer} Limit the number of products returned.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned products.
  • (query) fields {string} Comma-separated fields that should be included in the returned products.

x-codegen:

method: listProducts
queryParams: AdminGetPriceListsPriceListProductsParams

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.listProducts(priceListId) .then(({ products, limit, offset, count }) => { console.log(products.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminPriceListProducts } from "medusa-react"

    type Props = { priceListId: string }

    const PriceListProducts = ({ priceListId }: Props) => { const { products, isLoading } = useAdminPriceListProducts( priceListId )

    return ( <div> {isLoading && <span>Loading...</span>} {products && !products.length && ( <span>No Price Lists</span> )} {products && products.length > 0 && ( <ul> {products.map((product) => ( <li key={product.id}>{product.title}</li> ))} </ul> )} </div> ) }

    export default PriceListProducts

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/price-lists/{id}/products' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Price Lists

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPriceListsProductsListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*PriceList) SetRoutes

func (m *PriceList) SetRoutes(router fiber.Router)

func (*PriceList) Update

func (m *PriceList) Update(context fiber.Ctx) error

@oas:path [post] /admin/price-lists/{id} operationId: "PostPriceListsPriceListPriceList" summary: "Update a Price List" description: "Update a Price List's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Price List.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostPriceListsPriceListPriceListReq"

x-codegen:

method: update

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.update(priceListId, { name: "New Price List" }) .then(({ price_list }) => { console.log(price_list.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdatePriceList } from "medusa-react"

    type Props = { priceListId: string }

    const PriceList = ({ priceListId }: Props) => { const updatePriceList = useAdminUpdatePriceList(priceListId) // ...

    const handleUpdate = ( endsAt: Date ) => { updatePriceList.mutate({ ends_at: endsAt, }, { onSuccess: ({ price_list }) => { console.log(price_list.ends_at) } }) }

    // ... }

    export default PriceList

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/price-lists/{id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "name": "New Price List" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Price Lists

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPriceListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type Product

type Product struct {
	// contains filtered or unexported fields
}

func NewProduct

func NewProduct(r Registry) *Product

func (*Product) AddOption

func (m *Product) AddOption(context fiber.Ctx) error

@oas:path [post] /admin/products/{id}/options operationId: "PostProductsProductOptions" summary: "Add a Product Option" description: "Add a Product Option to a Product." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Product.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostProductsProductOptionsReq"

x-codegen:

method: addOption

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.products.addOption(productId, { title: "Size" }) .then(({ product }) => { console.log(product.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateProductOption } from "medusa-react"

    type Props = { productId: string }

    const CreateProductOption = ({ productId }: Props) => { const createOption = useAdminCreateProductOption( productId ) // ...

    const handleCreate = ( title: string ) => { createOption.mutate({ title }, { onSuccess: ({ product }) => { console.log(product.options) } }) }

    // ... }

    export default CreateProductOption

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/products/{id}/options' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "title": "Size" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Products

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Product) Create

func (m *Product) Create(context fiber.Ctx) error

@oas:path [post] /admin/products operationId: "PostProducts" summary: "Create a Product" x-authenticated: true description: "Create a new Product. This API Route can also be used to create a gift card if the `is_giftcard` field is set to `true`." requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostProductsReq"

x-codegen:

method: 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.products.create({ title: "Shirt", is_giftcard: false, discountable: true }) .then(({ product }) => { console.log(product.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateProduct } from "medusa-react"

    type CreateProductData = { title: string is_giftcard: boolean discountable: boolean options: { title: string }[] variants: { title: string prices: { amount: number currency_code :string }[] options: { value: string }[] }[], collection_id: string categories: { id: string }[] type: { value: string } tags: { value: string }[] }

    const CreateProduct = () => { const createProduct = useAdminCreateProduct() // ...

    const handleCreate = (productData: CreateProductData) => { createProduct.mutate(productData, { onSuccess: ({ product }) => { console.log(product.id) } }) }

    // ... }

    export default CreateProduct

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/products' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "title": "Shirt" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Products

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Product) CreateVariant

func (m *Product) CreateVariant(context fiber.Ctx) error

@oas:path [post] /admin/products/{id}/variants operationId: "PostProductsProductVariants" summary: "Create a Product Variant" description: "Create a Product Variant associated with a Product. Each product variant must have a unique combination of Product Option values." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Product.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostProductsProductVariantsReq"

x-codegen:

method: createVariant

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.products.createVariant(productId, { title: "Color", prices: [ { amount: 1000, currency_code: "eur" } ], options: [ { option_id, value: "S" } ], inventory_quantity: 100 }) .then(({ product }) => { console.log(product.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateVariant } from "medusa-react"

    type CreateVariantData = { title: string prices: { amount: number currency_code: string }[] options: { option_id: string value: string }[] }

    type Props = { productId: string }

    const CreateProductVariant = ({ productId }: Props) => { const createVariant = useAdminCreateVariant( productId ) // ...

    const handleCreate = ( variantData: CreateVariantData ) => { createVariant.mutate(variantData, { onSuccess: ({ product }) => { console.log(product.variants) } }) }

    // ... }

    export default CreateProductVariant

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/products/{id}/variants' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "title": "Color", "prices": [ { "amount": 1000, "currency_code": "eur" } ], "options": [ { "option_id": "asdasf", "value": "S" } ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Products

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Product) DeletOption

func (m *Product) DeletOption(context fiber.Ctx) error

@oas:path [delete] /admin/products/{id}/options/{option_id} operationId: "DeleteProductsProductOptionsOption" summary: "Delete a Product Option" description: "Delete a Product Option. If there are product variants that use this product option, they must be deleted before deleting the product option." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Product.
  • (path) option_id=* {string} The ID of the Product Option.

x-codegen:

method: deleteOption

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.products.deleteOption(productId, optionId) .then(({ option_id, object, deleted, product }) => { console.log(product.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteProductOption } from "medusa-react"

    type Props = { productId: string optionId: string }

    const ProductOption = ({ productId, optionId }: Props) => { const deleteOption = useAdminDeleteProductOption( productId ) // ...

    const handleDelete = () => { deleteOption.mutate(optionId, { onSuccess: ({ option_id, object, deleted, product }) => { console.log(product.options) } }) }

    // ... }

    export default ProductOption

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/products/{id}/options/{option_id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Products

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductsDeleteOptionRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Product) DeletVariant

func (m *Product) DeletVariant(context fiber.Ctx) error

@oas:path [delete] /admin/products/{id}/variants/{variant_id} operationId: "DeleteProductsProductVariantsVariant" summary: "Delete a Product Variant" description: "Delete a Product Variant." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Product.
  • (path) variant_id=* {string} The ID of the Product Variant.

x-codegen:

method: deleteVariant

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.products.deleteVariant(productId, variantId) .then(({ variant_id, object, deleted, product }) => { console.log(product.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteVariant } from "medusa-react"

    type Props = { productId: string variantId: string }

    const ProductVariant = ({ productId, variantId }: Props) => { const deleteVariant = useAdminDeleteVariant( productId ) // ...

    const handleDelete = () => { deleteVariant.mutate(variantId, { onSuccess: ({ variant_id, object, deleted, product }) => { console.log(product.variants) } }) }

    // ... }

    export default ProductVariant

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/products/{id}/variants/{variant_id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Products

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductsDeleteVariantRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Product) Delete

func (m *Product) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/products/{id} operationId: "DeleteProductsProduct" summary: "Delete a Product" description: "Delete a Product and its associated product variants and options." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Product.

x-codegen:

method: 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.products.delete(productId) .then(({ id, object, deleted }) => { console.log(id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteProduct } from "medusa-react"

    type Props = { productId: string }

    const Product = ({ productId }: Props) => { const deleteProduct = useAdminDeleteProduct( productId ) // ...

    const handleDelete = () => { deleteProduct.mutate(void 0, { onSuccess: ({ id, object, deleted}) => { console.log(id) } }) }

    // ... }

    export default Product

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/products/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Products

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductsDeleteRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Product) Get

func (m *Product) Get(context fiber.Ctx) error

@oas:path [get] /admin/products/{id} operationId: "GetProductsProduct" summary: "Get a Product" description: "Retrieve a Product's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Product.

x-codegen:

method: 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.products.retrieve(productId) .then(({ product }) => { console.log(product.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminProduct } from "medusa-react"

    type Props = { productId: string }

    const Product = ({ productId }: Props) => { const { product, isLoading, } = useAdminProduct(productId)

    return ( <div> {isLoading && <span>Loading...</span>} {product && <span>{product.title}</span>}

    </div> ) }

    export default Product

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/products/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Products

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Product) List

func (m *Product) List(context fiber.Ctx) error

@oas:path [get] /admin/products operationId: "GetProducts" summary: "List Products" description: "Retrieve a list of products. The products can be filtered by fields such as `q` or `status`. The products can also be sorted or paginated." x-authenticated: true parameters:

  • (query) q {string} term to search products' title, description, variants' title and sku, and collections' title.
  • (query) discount_condition_id {string} Filter by the ID of a discount condition. Only products that this discount condition is applied to will be retrieved.
  • in: query name: id style: form explode: false description: Filter by product IDs. schema: oneOf:
  • type: string description: ID of the product.
  • type: array items: type: string description: ID of a product.
  • in: query name: status style: form explode: false description: Filter by status. schema: type: array items: type: string enum: [draft, proposed, published, rejected]
  • in: query name: collection_id style: form explode: false description: Filter by product collection IDs. Only products that are associated with the specified collections will be retrieved. schema: type: array items: type: string
  • in: query name: tags style: form explode: false description: Filter by product tag IDs. Only products that are associated with the specified tags will be retrieved. schema: type: array items: type: string
  • in: query name: price_list_id style: form explode: false description: Filter by IDs of price lists. Only products that these price lists are applied to will be retrieved. schema: type: array items: type: string
  • in: query name: sales_channel_id style: form explode: false description: Filter by sales channel IDs. Only products that are available in the specified sales channels will be retrieved. schema: type: array items: type: string
  • in: query name: type_id style: form explode: false description: Filter by product type IDs. Only products that are associated with the specified types will be retrieved. schema: type: array items: type: string
  • in: query name: category_id style: form explode: false description: Filter by product category IDs. Only products that are associated with the specified categories will be retrieved. schema: type: array x-featureFlag: "product_categories" items: type: string
  • in: query name: include_category_children style: form explode: false description: whether to include product category children when filtering by `category_id` schema: type: boolean x-featureFlag: "product_categories"
  • (query) title {string} Filter by title.
  • (query) description {string} Filter by description.
  • (query) handle {string} Filter by handle.
  • (query) is_giftcard {boolean} Whether to retrieve gift cards or regular products.
  • in: query name: created_at description: Filter by a creation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: updated_at description: Filter by an update date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: deleted_at description: Filter by a deletion date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • (query) offset=0 {integer} The number of products to skip when retrieving the products.
  • (query) limit=50 {integer} Limit the number of products returned.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned products.
  • (query) fields {string} Comma-separated fields that should be included in the returned products.
  • (query) order {string} A product field to sort-order the retrieved products by.

x-codegen:

method: list
queryParams: AdminGetProductsParams

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.products.list() .then(({ products, limit, offset, count }) => { console.log(products.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminProducts } from "medusa-react"

    const Products = () => { const { products, isLoading } = useAdminProducts()

    return ( <div> {isLoading && <span>Loading...</span>} {products && !products.length && <span>No Products</span>} {products && products.length > 0 && ( <ul> {products.map((product) => ( <li key={product.id}>{product.title}</li> ))} </ul> )} </div> ) }

    export default Products

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/products' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Products

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductsListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Product) ListTagUsageCount

func (m *Product) ListTagUsageCount(context fiber.Ctx) error

@oas:path [get] /admin/products/tag-usage operationId: "GetProductsTagUsage" summary: "List Tags Usage Number" description: "Retrieve a list of Product Tags with how many times each is used in products." x-authenticated: true x-codegen:

method: listTags

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.products.listTags() .then(({ tags }) => { console.log(tags.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminProductTagUsage } from "medusa-react"

    const ProductTags = (productId: string) => { const { tags, isLoading } = useAdminProductTagUsage()

    return ( <div> {isLoading && <span>Loading...</span>} {tags && !tags.length && <span>No Product Tags</span>} {tags && tags.length > 0 && ( <ul> {tags.map((tag) => ( <li key={tag.id}>{tag.value} - {tag.usage_count}</li> ))} </ul> )} </div> ) }

    export default ProductTags

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/products/tag-usage' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Products

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductsListTagsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Product) ListTypes

func (m *Product) ListTypes(context fiber.Ctx) error

@oas:path [get] /admin/products/types deprecated: true operationId: "GetProductsTypes" summary: "List Product Types" description: "Retrieve a list of Product Types." x-authenticated: true x-codegen:

method: listTypes

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.products.listTypes() .then(({ types }) => { console.log(types.length); })
  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/products/types' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Products

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductsListTypesRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Product) ListVariants

func (m *Product) ListVariants(context fiber.Ctx) error

@oas:path [get] /admin/products/{id}/variants operationId: "GetProductsProductVariants" summary: "List a Product's Variants" description: |

Retrieve a list of Product Variants associated with a Product. The variants can be paginated.

By default, each variant will only have the `id` and `variant_id` fields. You can use the `expand` and `fields` request parameters to retrieve more fields or relations.

x-authenticated: true parameters:

  • (path) id=* {string} ID of the product.
  • (query) fields {string} Comma-separated fields that should be included in the returned product variants.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned product variants.
  • (query) offset=0 {integer} The number of product variants to skip when retrieving the product variants.
  • (query) limit=100 {integer} Limit the number of product variants returned.

x-codegen:

method: listVariants
queryParams: AdminGetProductsVariantsParams

x-codeSamples:

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/products/{id}/variants' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Products

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductsListVariantsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Product) SetMetadata

func (m *Product) SetMetadata(context fiber.Ctx) error

@oas:path [post] /admin/products/{id}/metadata operationId: "PostProductsProductMetadata" summary: "Set Metadata" description: "Set the metadata of a Product. It can be any key-value pair, which allows adding custom data to a product." externalDocs:

description: "Learn about the metadata attribute, and how to delete and update it."
url: "https://docs.medusajs.com/development/entities/overview#metadata-attribute"

x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Product.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostProductsProductMetadataReq"

x-codegen:

method: setMetadata

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.products.setMetadata(productId, { key: "test", value: "true" }) .then(({ product }) => { console.log(product.id); })
  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/products/{id}/metadata' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "key": "test", "value": "true" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Products

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Product) SetRoutes

func (m *Product) SetRoutes(router fiber.Router)

func (*Product) Update

func (m *Product) Update(context fiber.Ctx) error

@oas:path [post] /admin/products/{id} operationId: "PostProductsProduct" summary: "Update a Product" description: "Update a Product's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Product.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostProductsProductReq"

x-codegen:

method: update

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.products.update(productId, { title: "Shirt", }) .then(({ product }) => { console.log(product.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateProduct } from "medusa-react"

    type Props = { productId: string }

    const Product = ({ productId }: Props) => { const updateProduct = useAdminUpdateProduct( productId ) // ...

    const handleUpdate = ( title: string ) => { updateProduct.mutate({ title, }, { onSuccess: ({ product }) => { console.log(product.id) } }) }

    // ... }

    export default Product

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/products/{id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "title": "Size" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Products

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Product) UpdateOption

func (m *Product) UpdateOption(context fiber.Ctx) error

@oas:path [post] /admin/products/{id}/options/{option_id} operationId: "PostProductsProductOptionsOption" summary: "Update a Product Option" description: "Update a Product Option's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Product.
  • (path) option_id=* {string} The ID of the Product Option.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostProductsProductOptionsOption"

x-codegen:

method: updateOption

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.products.updateOption(productId, optionId, { title: "Size" }) .then(({ product }) => { console.log(product.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateProductOption } from "medusa-react"

    type Props = { productId: string optionId: string }

    const ProductOption = ({ productId, optionId }: Props) => { const updateOption = useAdminUpdateProductOption( productId ) // ...

    const handleUpdate = ( title: string ) => { updateOption.mutate({ option_id: optionId, title, }, { onSuccess: ({ product }) => { console.log(product.options) } }) }

    // ... }

    export default ProductOption

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/products/{id}/options/{option_id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "title": "Size" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Products

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Product) UpdateVariant

func (m *Product) UpdateVariant(context fiber.Ctx) error

@oas:path [post] /admin/products/{id}/variants/{variant_id} operationId: "PostProductsProductVariantsVariant" summary: "Update a Product Variant" description: "Update a Product Variant's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Product.
  • (path) variant_id=* {string} The ID of the Product Variant.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostProductsProductVariantsVariantReq"

x-codegen:

method: updateVariant

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.products.updateVariant(productId, variantId, { title: "Color", prices: [ { amount: 1000, currency_code: "eur" } ], options: [ { option_id, value: "S" } ], inventory_quantity: 100 }) .then(({ product }) => { console.log(product.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateVariant } from "medusa-react"

    type Props = { productId: string variantId: string }

    const ProductVariant = ({ productId, variantId }: Props) => { const updateVariant = useAdminUpdateVariant( productId ) // ...

    const handleUpdate = (title: string) => { updateVariant.mutate({ variant_id: variantId, title, }, { onSuccess: ({ product }) => { console.log(product.variants) } }) }

    // ... }

    export default ProductVariant

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/products/{id}/variants/{variant_id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "title": "Color", "prices": [ { "amount": 1000, "currency_code": "eur" } ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Products

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type ProductCategory

type ProductCategory struct {
	// contains filtered or unexported fields
}

func NewProductCategory

func NewProductCategory(r Registry) *ProductCategory

func (*ProductCategory) AddProductsBatch

func (m *ProductCategory) AddProductsBatch(context fiber.Ctx) error

@oas:path [post] /admin/product-categories/{id}/products/batch operationId: "PostProductCategoriesCategoryProductsBatch" summary: "Add Products to a Category" description: "Add a list of products to a product category." x-authenticated: true x-featureFlag: "product_categories" parameters:

  • (path) id=* {string} The ID of the Product Category.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned product category.
  • (query) fields {string} Comma-separated fields that should be included in the returned product category.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostProductCategoriesCategoryProductsBatchReq"

x-codegen:

method: addProducts
queryParams: AdminPostProductCategoriesCategoryProductsBatchParams

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.productCategories.addProducts(productCategoryId, { product_ids: [ { id: productId } ] }) .then(({ product_category }) => { console.log(product_category.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminAddProductsToCategory } from "medusa-react"

    type ProductsData = { id: string }

    type Props = { productCategoryId: string }

    const Category = ({ productCategoryId }: Props) => { const addProducts = useAdminAddProductsToCategory( productCategoryId ) // ...

    const handleAddProducts = ( productIds: ProductsData[] ) => { addProducts.mutate({ product_ids: productIds }, { onSuccess: ({ product_category }) => { console.log(product_category.products) } }) }

    // ... }

    export default Category

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/product-categories/{id}/products/batch' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "product_ids": [ { "id": "{product_id}" } ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Product Categories

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductCategoriesCategoryRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*ProductCategory) Create

func (m *ProductCategory) Create(context fiber.Ctx) error

@oas:path [post] /admin/product-categories operationId: "PostProductCategories" summary: "Create a Product Category" description: "Create a Product Category." x-authenticated: true x-featureFlag: "product_categories" parameters:

  • (query) expand {string} Comma-separated relations that should be expanded in the returned product category.
  • (query) fields {string} Comma-separated fields that should be included in the returned product category.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostProductCategoriesReq"

x-codegen:

method: create
queryParams: AdminPostProductCategoriesParams

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.productCategories.create({ name: "Skinny Jeans", }) .then(({ product_category }) => { console.log(product_category.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateProductCategory } from "medusa-react"

    const CreateCategory = () => { const createCategory = useAdminCreateProductCategory() // ...

    const handleCreate = ( name: string ) => { createCategory.mutate({ name, }, { onSuccess: ({ product_category }) => { console.log(product_category.id) } }) }

    // ... }

    export default CreateCategory

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/product-categories' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "name": "Skinny Jeans" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Product Categories

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductCategoriesCategoryRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*ProductCategory) Delete

func (m *ProductCategory) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/product-categories/{id} operationId: "DeleteProductCategoriesCategory" summary: "Delete a Product Category" description: "Delete a Product Category. This does not delete associated products." x-authenticated: true x-featureFlag: "product_categories" parameters:

  • (path) id=* {string} The ID of the Product Category

x-codegen:

method: 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.productCategories.delete(productCategoryId) .then(({ id, object, deleted }) => { console.log(id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteProductCategory } from "medusa-react"

    type Props = { productCategoryId: string }

    const Category = ({ productCategoryId }: Props) => { const deleteCategory = useAdminDeleteProductCategory( productCategoryId ) // ...

    const handleDelete = () => { deleteCategory.mutate(void 0, { onSuccess: ({ id, object, deleted }) => { console.log(id) } }) }

    // ... }

    export default Category

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/product-categories/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Product Categories

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductCategoriesCategoryDeleteRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*ProductCategory) DeleteProductsBatch

func (m *ProductCategory) DeleteProductsBatch(context fiber.Ctx) error

@oas:path [delete] /admin/product-categories/{id}/products/batch operationId: "DeleteProductCategoriesCategoryProductsBatch" summary: "Remove Products from Category" description: "Remove a list of products from a product category." x-authenticated: true x-featureFlag: "product_categories" parameters:

  • (path) id=* {string} The ID of the Product Category.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned product category.
  • (query) fields {string} Comma-separated fields that should be included in the returned product category.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminDeleteProductCategoriesCategoryProductsBatchReq"

x-codegen:

method: removeProducts
queryParams: AdminDeleteProductCategoriesCategoryProductsBatchParams

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.productCategories.removeProducts(productCategoryId, { product_ids: [ { id: productId } ] }) .then(({ product_category }) => { console.log(product_category.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteProductsFromCategory } from "medusa-react"

    type ProductsData = { id: string }

    type Props = { productCategoryId: string }

    const Category = ({ productCategoryId }: Props) => { const deleteProducts = useAdminDeleteProductsFromCategory( productCategoryId ) // ...

    const handleDeleteProducts = ( productIds: ProductsData[] ) => { deleteProducts.mutate({ product_ids: productIds }, { onSuccess: ({ product_category }) => { console.log(product_category.products) } }) }

    // ... }

    export default Category

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/product-categories/{id}/products/batch' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "product_ids": [ { "id": "{product_id}" } ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Product Categories

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductCategoriesCategoryRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*ProductCategory) Get

func (m *ProductCategory) Get(context fiber.Ctx) error

@oas:path [get] /admin/product-categories/{id} operationId: "GetProductCategoriesCategory" summary: "Get a Product Category" description: "Retrieve a Product Category's details." x-authenticated: true x-featureFlag: "product_categories" parameters:

  • (path) id=* {string} The ID of the Product Category
  • (query) expand {string} Comma-separated relations that should be expanded in the returned product category.
  • (query) fields {string} Comma-separated fields that should be included in the returned product category.

x-codegen:

method: retrieve
queryParams: AdminGetProductCategoryParams

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.productCategories.retrieve(productCategoryId) .then(({ product_category }) => { console.log(product_category.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminProductCategory } from "medusa-react"

    type Props = { productCategoryId: string }

    const Category = ({ productCategoryId }: Props) => { const { product_category, isLoading, } = useAdminProductCategory(productCategoryId)

    return ( <div> {isLoading && <span>Loading...</span>} {product_category && ( <span>{product_category.name}</span> )}

    </div> ) }

    export default Category

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/product-categories/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Product Categories

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductCategoriesCategoryRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*ProductCategory) List

func (m *ProductCategory) List(context fiber.Ctx) error

@oas:path [get] /admin/product-categories operationId: "GetProductCategories" summary: "List Product Categories" description: "Retrieve a list of product categories. The product categories can be filtered by fields such as `q` or `handle`. The product categories can also be paginated." x-authenticated: true x-featureFlag: "product_categories" parameters:

  • (query) q {string} term to search product categories' names and handles.
  • (query) handle {string} Filter by handle.
  • (query) is_internal {boolean} Filter by whether the category is internal or not.
  • (query) is_active {boolean} Filter by whether the category is active or not.
  • (query) include_descendants_tree {boolean} If set to `true`, all nested descendants of a category are included in the response.
  • (query) parent_category_id {string} Filter by the ID of a parent category.
  • (query) offset=0 {integer} The number of product categories to skip when retrieving the product categories.
  • (query) limit=100 {integer} Limit the number of product categories returned.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned product categories.
  • (query) fields {string} Comma-separated fields that should be included in the returned product categories.

x-codegen:

method: list
queryParams: AdminGetProductCategoriesParams

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.productCategories.list() .then(({ product_categories, limit, offset, count }) => { console.log(product_categories.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminProductCategories } from "medusa-react"

    function Categories() { const { product_categories, isLoading } = useAdminProductCategories()

    return ( <div> {isLoading && <span>Loading...</span>} {product_categories && !product_categories.length && ( <span>No Categories</span> )} {product_categories && product_categories.length > 0 && ( <ul> {product_categories.map( (category) => ( <li key={category.id}>{category.name}</li> ) )} </ul> )} </div> ) }

    export default Categories

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/product-categories' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Product Categories

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductCategoriesListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*ProductCategory) SetRoutes

func (m *ProductCategory) SetRoutes(router fiber.Router)

func (*ProductCategory) Update

func (m *ProductCategory) Update(context fiber.Ctx) error

@oas:path [post] /admin/product-categories/{id} operationId: "PostProductCategoriesCategory" summary: "Update a Product Category" description: "Updates a Product Category." x-authenticated: true x-featureFlag: "product_categories" parameters:

  • (path) id=* {string} The ID of the Product Category.
  • (query) expand {string} (Comma separated) Which fields should be expanded in each product category.
  • (query) fields {string} (Comma separated) Which fields should be retrieved in each product category.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostProductCategoriesCategoryReq"

x-codegen:

method: update
queryParams: AdminPostProductCategoriesCategoryParams

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.productCategories.update(productCategoryId, { name: "Skinny Jeans" }) .then(({ product_category }) => { console.log(product_category.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateProductCategory } from "medusa-react"

    type Props = { productCategoryId: string }

    const Category = ({ productCategoryId }: Props) => { const updateCategory = useAdminUpdateProductCategory( productCategoryId ) // ...

    const handleUpdate = ( name: string ) => { updateCategory.mutate({ name, }, { onSuccess: ({ product_category }) => { console.log(product_category.id) } }) }

    // ... }

    export default Category

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/product-categories/{id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "name": "Skinny Jeans" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Product Categories

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductCategoriesCategoryRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type ProductTag

type ProductTag struct {
	// contains filtered or unexported fields
}

func NewProductTag

func NewProductTag(r Registry) *ProductTag

func (*ProductTag) List

func (m *ProductTag) List(context fiber.Ctx) error

@oas:path [get] /admin/product-tags operationId: "GetProductTags" summary: "List Product Tags" description: "Retrieve a list of product tags. The product tags can be filtered by fields such as `q` or `value`. The product tags can also be sorted or paginated." x-authenticated: true parameters:

  • (query) limit=10 {integer} Limit the number of product tags returned.
  • (query) offset=0 {integer} The number of product tags to skip when retrieving the product tags.
  • (query) order {string} A product tag field to sort-order the retrieved product tags by.
  • (query) discount_condition_id {string} Filter by the ID of a discount condition. Only product tags that this discount condition is applied to will be retrieved.
  • in: query name: value style: form explode: false description: Filter by tag value. schema: type: array items: type: string
  • (query) q {string} term to search product tags' values.
  • in: query name: id style: form explode: false description: Filter by tag IDs. schema: type: array items: type: string
  • in: query name: created_at description: Filter by a creation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: updated_at description: Filter by an update date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date

x-codegen:

method: list
queryParams: AdminGetProductTagsParams

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.productTags.list() .then(({ product_tags }) => { console.log(product_tags.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminProductTags } from "medusa-react"

    function ProductTags() { const { product_tags, isLoading } = useAdminProductTags()

    return ( <div> {isLoading && <span>Loading...</span>} {product_tags && !product_tags.length && ( <span>No Product Tags</span> )} {product_tags && product_tags.length > 0 && ( <ul> {product_tags.map( (tag) => ( <li key={tag.id}>{tag.value}</li> ) )} </ul> )} </div> ) }

    export default ProductTags

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/product-tags' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Product Tags

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductTagsListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*ProductTag) SetRoutes

func (m *ProductTag) SetRoutes(router fiber.Router)

type ProductType

type ProductType struct {
	// contains filtered or unexported fields
}

func NewProductType

func NewProductType(r Registry) *ProductType

func (*ProductType) List

func (m *ProductType) List(context fiber.Ctx) error

@oas:path [get] /admin/product-types operationId: "GetProductTypes" summary: "List Product Types" description: "Retrieve a list of product types. The product types can be filtered by fields such as `q` or `value`. The product types can also be sorted or paginated." x-authenticated: true parameters:

  • (query) limit=20 {integer} Limit the number of product types returned.
  • (query) offset=0 {integer} The number of product types to skip when retrieving the product types.
  • (query) order {string} A product type field to sort-order the retrieved product types by.
  • (query) discount_condition_id {string} Filter by the ID of a discount condition. Only product types that this discount condition is applied to will be retrieved.
  • in: query name: value style: form explode: false description: Filter by value. schema: type: array items: type: string
  • in: query name: id style: form explode: false description: Filter by product type IDs. schema: type: array items: type: string
  • (query) q {string} term to search product types' values.
  • in: query name: created_at description: Filter by a creation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: updated_at description: Filter by an update date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date

x-codegen:

method: list
queryParams: AdminGetProductTypesParams

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.productTypes.list() .then(({ product_types }) => { console.log(product_types.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminProductTypes } from "medusa-react"

    function ProductTypes() { const { product_types, isLoading } = useAdminProductTypes()

    return ( <div> {isLoading && <span>Loading...</span>} {product_types && !product_types.length && ( <span>No Product Tags</span> )} {product_types && product_types.length > 0 && ( <ul> {product_types.map( (type) => ( <li key={type.id}>{type.value}</li> ) )} </ul> )} </div> ) }

    export default ProductTypes

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/product-types' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Product Types

responses:

"200":
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminProductTypesListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*ProductType) SetRoutes

func (m *ProductType) SetRoutes(router fiber.Router)

type PublishableApiKey

type PublishableApiKey struct {
	// contains filtered or unexported fields
}

func NewPublishableApiKey

func NewPublishableApiKey(r Registry) *PublishableApiKey

func (*PublishableApiKey) AddChannelsBatch

func (m *PublishableApiKey) AddChannelsBatch(context fiber.Ctx) error

@oas:path [post] /admin/publishable-api-keys/{id}/sales-channels/batch operationId: "PostPublishableApiKeySalesChannelsChannelsBatch" summary: "Add Sales Channels" description: "Add a list of sales channels to a publishable API key." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Publishable Api Key.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostPublishableApiKeySalesChannelsBatchReq"

x-codegen:

method: addSalesChannelsBatch

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.publishableApiKeys.addSalesChannelsBatch(publishableApiKeyId, { sales_channel_ids: [ { id: channelId } ] }) .then(({ publishable_api_key }) => { console.log(publishable_api_key.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminAddPublishableKeySalesChannelsBatch, } from "medusa-react"

    type Props = { publishableApiKeyId: string }

    const PublishableApiKey = ({ publishableApiKeyId }: Props) => { const addSalesChannels = useAdminAddPublishableKeySalesChannelsBatch( publishableApiKeyId ) // ...

    const handleAdd = (salesChannelId: string) => { addSalesChannels.mutate({ sales_channel_ids: [ { id: salesChannelId, }, ], }, { onSuccess: ({ publishable_api_key }) => { console.log(publishable_api_key.id) } }) }

    // ... }

    export default PublishableApiKey

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/publishable-api-keys/{pak_id}/batch' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "sales_channel_ids": [ { "id": "{sales_channel_id}" } ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Publishable Api Keys

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPublishableApiKeysRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*PublishableApiKey) Create

func (m *PublishableApiKey) Create(context fiber.Ctx) error

@oas:path [post] /admin/publishable-api-keys operationId: "PostPublishableApiKeys" summary: "Create Publishable API Key" description: "Create a Publishable API Key." requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostPublishableApiKeysReq"

x-authenticated: true x-codegen:

method: 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.publishableApiKeys.create({ title }) .then(({ publishable_api_key }) => { console.log(publishable_api_key.id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreatePublishableApiKey } from "medusa-react"

    const CreatePublishableApiKey = () => { const createKey = useAdminCreatePublishableApiKey() // ...

    const handleCreate = (title: string) => { createKey.mutate({ title, }, { onSuccess: ({ publishable_api_key }) => { console.log(publishable_api_key.id) } }) }

    // ... }

    export default CreatePublishableApiKey

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/publishable-api-keys' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "title": "Web API Key" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Publishable Api Keys

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPublishableApiKeysRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*PublishableApiKey) Delete

func (m *PublishableApiKey) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/publishable-api-keys/{id} operationId: "DeletePublishableApiKeysPublishableApiKey" summary: "Delete Publishable API Key" description: "Delete a Publishable API Key. Associated resources, such as sales channels, are not deleted." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Publishable API Key to delete.

x-codegen:

method: 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.publishableApiKeys.delete(publishableApiKeyId) .then(({ id, object, deleted }) => { console.log(id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeletePublishableApiKey } from "medusa-react"

    type Props = { publishableApiKeyId: string }

    const PublishableApiKey = ({ publishableApiKeyId }: Props) => { const deleteKey = useAdminDeletePublishableApiKey( publishableApiKeyId ) // ...

    const handleDelete = () => { deleteKey.mutate(void 0, { onSuccess: ({ id, object, deleted }) => { console.log(id) } }) }

    // ... }

    export default PublishableApiKey

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/publishable-api-key/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Publishable Api Keys

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPublishableApiKeyDeleteRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"

func (*PublishableApiKey) DeleteChannelsBatch

func (m *PublishableApiKey) DeleteChannelsBatch(context fiber.Ctx) error

@oas:path [delete] /admin/publishable-api-keys/{id}/sales-channels/batch operationId: "DeletePublishableApiKeySalesChannelsChannelsBatch" summary: "Remove Sales Channels" description: "Remove a list of sales channels from a publishable API key. This doesn't delete the sales channels and only removes the association between them and the publishable API key." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Publishable API Key.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminDeletePublishableApiKeySalesChannelsBatchReq"

x-codegen:

method: deleteSalesChannelsBatch

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.publishableApiKeys.deleteSalesChannelsBatch(publishableApiKeyId, { sales_channel_ids: [ { id: channelId } ] }) .then(({ publishable_api_key }) => { console.log(publishable_api_key.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminRemovePublishableKeySalesChannelsBatch, } from "medusa-react"

    type Props = { publishableApiKeyId: string }

    const PublishableApiKey = ({ publishableApiKeyId }: Props) => { const deleteSalesChannels = useAdminRemovePublishableKeySalesChannelsBatch( publishableApiKeyId ) // ...

    const handleDelete = (salesChannelId: string) => { deleteSalesChannels.mutate({ sales_channel_ids: [ { id: salesChannelId, }, ], }, { onSuccess: ({ publishable_api_key }) => { console.log(publishable_api_key.id) } }) }

    // ... }

    export default PublishableApiKey

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/publishable-api-keys/{id}/batch' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "sales_channel_ids": [ { "id": "{sales_channel_id}" } ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Publishable Api Keys

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPublishableApiKeysRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*PublishableApiKey) Get

func (m *PublishableApiKey) Get(context fiber.Ctx) error

@oas:path [get] /admin/publishable-api-keys/{id} operationId: "GetPublishableApiKeysPublishableApiKey" summary: "Get a Publishable API Key" description: "Retrieve a publishable API key's details." parameters:

  • (path) id=* {string} The ID of the Publishable API Key.

x-authenticated: true x-codegen:

method: 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.publishableApiKeys.retrieve(publishableApiKeyId) .then(({ publishable_api_key }) => { console.log(publishable_api_key.id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeletePublishableApiKey } from "medusa-react"

    type Props = { publishableApiKeyId: string }

    const PublishableApiKey = ({ publishableApiKeyId }: Props) => { const deleteKey = useAdminDeletePublishableApiKey( publishableApiKeyId ) // ...

    const handleDelete = () => { deleteKey.mutate(void 0, { onSuccess: ({ id, object, deleted }) => { console.log(id) } }) }

    // ... }

    export default PublishableApiKey

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/publishable-api-keys/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Publishable Api Keys

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPublishableApiKeysRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*PublishableApiKey) List

func (m *PublishableApiKey) List(context fiber.Ctx) error

@oas:path [get] /admin/publishable-api-keys operationId: "GetPublishableApiKeys" summary: "List Publishable API keys" description: "Retrieve a list of publishable API keys. The publishable API keys can be filtered by fields such as `q`. The publishable API keys can also be paginated." x-authenticated: true parameters:

  • (query) q {string} term to search publishable API keys' titles.
  • (query) limit=20 {number} Limit the number of publishable API keys returned.
  • (query) offset=0 {number} The number of publishable API keys to skip when retrieving the publishable API keys.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned publishable API keys.
  • (query) fields {string} Comma-separated fields that should be included in the returned publishable API keys.

x-codegen:

method: list
queryParams: GetPublishableApiKeysParams

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.publishableApiKeys.list() .then(({ publishable_api_keys, count, limit, offset }) => { console.log(publishable_api_keys) })

  • lang: tsx label: Medusa React source: | import React from "react" import { PublishableApiKey } from "@medusajs/medusa" import { useAdminPublishableApiKeys } from "medusa-react"

    const PublishableApiKeys = () => { const { publishable_api_keys, isLoading } = useAdminPublishableApiKeys()

    return ( <div> {isLoading && <span>Loading...</span>} {publishable_api_keys && !publishable_api_keys.length && ( <span>No Publishable API Keys</span> )} {publishable_api_keys && publishable_api_keys.length > 0 && ( <ul> {publishable_api_keys.map( (publishableApiKey: PublishableApiKey) => ( <li key={publishableApiKey.id}> {publishableApiKey.title} </li> ) )} </ul> )} </div> ) }

    export default PublishableApiKeys

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/publishable-api-keys' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Publishable Api Keys

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPublishableApiKeysListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*PublishableApiKey) ListChannels

func (m *PublishableApiKey) ListChannels(context fiber.Ctx) error

@oas:path [get] /admin/publishable-api-keys/{id}/sales-channels operationId: "GetPublishableApiKeySalesChannels" summary: "List Sales Channels" description: "List the sales channels associated with a publishable API key. The sales channels can be filtered by fields such as `q`." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the publishable API key.
  • (query) q {string} query to search sales channels' names and descriptions.

x-codegen:

method: listSalesChannels
queryParams: GetPublishableApiKeySalesChannelsParams

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.publishableApiKeys.listSalesChannels() .then(({ sales_channels }) => { console.log(sales_channels.length) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminPublishableApiKeySalesChannels, } from "medusa-react"

    type Props = { publishableApiKeyId: string }

    const SalesChannels = ({ publishableApiKeyId }: Props) => { const { sales_channels, isLoading } = useAdminPublishableApiKeySalesChannels( publishableApiKeyId )

    return ( <div> {isLoading && <span>Loading...</span>} {sales_channels && !sales_channels.length && ( <span>No Sales Channels</span> )} {sales_channels && sales_channels.length > 0 && ( <ul> {sales_channels.map((salesChannel) => ( <li key={salesChannel.id}>{salesChannel.name}</li> ))} </ul> )} </div> ) }

    export default SalesChannels

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/publishable-api-keys/{id}/sales-channels' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Publishable Api Keys

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPublishableApiKeysListSalesChannelsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*PublishableApiKey) Revoke

func (m *PublishableApiKey) Revoke(context fiber.Ctx) error

@oas:path [post] /admin/publishable-api-keys/{id}/revoke operationId: "PostPublishableApiKeysPublishableApiKeyRevoke" summary: "Revoke a Publishable API Key" description: "Revoke a Publishable API Key. Revoking the publishable API Key can't be undone, and the key can't be used in future requests." parameters:

  • (path) id=* {string} The ID of the Publishable API Key.

x-authenticated: true x-codegen:

method: revoke

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.publishableApiKeys.revoke(publishableApiKeyId) .then(({ publishable_api_key }) => { console.log(publishable_api_key.id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminRevokePublishableApiKey } from "medusa-react"

    type Props = { publishableApiKeyId: string }

    const PublishableApiKey = ({ publishableApiKeyId }: Props) => { const revokeKey = useAdminRevokePublishableApiKey( publishableApiKeyId ) // ...

    const handleRevoke = () => { revokeKey.mutate(void 0, { onSuccess: ({ publishable_api_key }) => { console.log(publishable_api_key.revoked_at) } }) }

    // ... }

    export default PublishableApiKey

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/publishable-api-keys/{id}/revoke' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Publishable Api Keys

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPublishableApiKeysRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*PublishableApiKey) SetRoutes

func (m *PublishableApiKey) SetRoutes(router fiber.Router)

func (*PublishableApiKey) Update

func (m *PublishableApiKey) Update(context fiber.Ctx) error

@oas:path [post] /admin/publishable-api-keys/{id} operationId: "PostPublishableApiKysPublishableApiKey" summary: "Update Publishable API Key" description: "Update a Publishable API Key's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Publishable API Key.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostPublishableApiKeysPublishableApiKeyReq"

x-codegen:

method: update

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.publishableApiKeys.update(publishableApiKeyId, { title: "new title" }) .then(({ publishable_api_key }) => { console.log(publishable_api_key.id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdatePublishableApiKey } from "medusa-react"

    type Props = { publishableApiKeyId: string }

    const PublishableApiKey = ({ publishableApiKeyId }: Props) => { const updateKey = useAdminUpdatePublishableApiKey( publishableApiKeyId ) // ...

    const handleUpdate = (title: string) => { updateKey.mutate({ title, }, { onSuccess: ({ publishable_api_key }) => { console.log(publishable_api_key.id) } }) }

    // ... }

    export default PublishableApiKey

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/publishable-api-key/{id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "title": "new title" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Publishable Api Keys

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPublishableApiKeysRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type Region

type Region struct {
	// contains filtered or unexported fields
}

func NewRegion

func NewRegion(r Registry) *Region

func (*Region) AddCountry

func (m *Region) AddCountry(context fiber.Ctx) error

@oas:path [post] /admin/regions/{id}/countries operationId: "PostRegionsRegionCountries" summary: "Add Country" description: "Add a Country to the list of Countries in a Region." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Region.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostRegionsRegionCountriesReq"

x-codegen:

method: addCountry

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.regions.addCountry(regionId, { country_code: "dk" }) .then(({ region }) => { console.log(region.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminRegionAddCountry } from "medusa-react"

    type Props = { regionId: string }

    const Region = ({ regionId }: Props) => { const addCountry = useAdminRegionAddCountry(regionId) // ...

    const handleAddCountry = ( countryCode: string ) => { addCountry.mutate({ country_code: countryCode }, { onSuccess: ({ region }) => { console.log(region.countries) } }) }

    // ... }

    export default Region

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/regions/{region_id}/countries' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "country_code": "dk" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Regions

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminRegionsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Region) AddFullfilmentProvider

func (m *Region) AddFullfilmentProvider(context fiber.Ctx) error

@oas:path [post] /admin/regions/{id}/fulfillment-providers operationId: "PostRegionsRegionFulfillmentProviders" summary: "Add Fulfillment Provider" description: "Add a Fulfillment Provider to the list of fulfullment providers in a Region." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Region.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostRegionsRegionFulfillmentProvidersReq"

x-codegen:

method: addFulfillmentProvider

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.regions.addFulfillmentProvider(regionId, { provider_id: "manual" }) .then(({ region }) => { console.log(region.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminRegionAddFulfillmentProvider } from "medusa-react"

    type Props = { regionId: string }

    const Region = ({ regionId }: Props) => { const addFulfillmentProvider = useAdminRegionAddFulfillmentProvider(regionId) // ...

    const handleAddFulfillmentProvider = ( providerId: string ) => { addFulfillmentProvider.mutate({ provider_id: providerId }, { onSuccess: ({ region }) => { console.log(region.fulfillment_providers) } }) }

    // ... }

    export default Region

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/regions/{id}/fulfillment-providers' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "provider_id": "manual" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Regions

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminRegionsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Region) AddPaymentProvider

func (m *Region) AddPaymentProvider(context fiber.Ctx) error

@oas:path [post] /admin/regions/{id}/payment-providers operationId: "PostRegionsRegionPaymentProviders" summary: "Add Payment Provider" description: "Add a Payment Provider to the list of payment providers in a Region." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Region.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostRegionsRegionPaymentProvidersReq"

x-codegen:

method: addPaymentProvider

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.regions.addPaymentProvider(regionId, { provider_id: "manual" }) .then(({ region }) => { console.log(region.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminRegionAddPaymentProvider } from "medusa-react"

    type Props = { regionId: string }

    const Region = ({ regionId }: Props) => { const addPaymentProvider = useAdminRegionAddPaymentProvider(regionId) // ...

    const handleAddPaymentProvider = ( providerId: string ) => { addPaymentProvider.mutate({ provider_id: providerId }, { onSuccess: ({ region }) => { console.log(region.payment_providers) } }) }

    // ... }

    export default Region

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/regions/{id}/payment-providers' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "provider_id": "manual" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Regions

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminRegionsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Region) Create

func (m *Region) Create(context fiber.Ctx) error

@oas:path [post] /admin/regions operationId: "PostRegions" summary: "Create a Region" description: "Create a Region." x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostRegionsReq"

x-codegen:

method: 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.regions.create({ name: "Europe", currency_code: "eur", tax_rate: 0, payment_providers: [ "manual" ], fulfillment_providers: [ "manual" ], countries: [ "DK" ] }) .then(({ region }) => { console.log(region.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateRegion } from "medusa-react"

    type CreateData = { name: string currency_code: string tax_rate: number payment_providers: string[] fulfillment_providers: string[] countries: string[] }

    const CreateRegion = () => { const createRegion = useAdminCreateRegion() // ...

    const handleCreate = (regionData: CreateData) => { createRegion.mutate(regionData, { onSuccess: ({ region }) => { console.log(region.id) } }) }

    // ... }

    export default CreateRegion

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/regions' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "name": "Europe", "currency_code": "eur", "tax_rate": 0, "payment_providers": [ "manual" ], "fulfillment_providers": [ "manual" ], "countries": [ "DK" ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Regions

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminRegionsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Region) Delete

func (m *Region) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/regions/{id} operationId: "DeleteRegionsRegion" summary: "Delete a Region" description: "Delete a Region. Associated resources, such as providers or currencies are not deleted. Associated tax rates are deleted." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Region.

x-codegen:

method: 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.regions.delete(regionId) .then(({ id, object, deleted }) => { console.log(id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteRegion } from "medusa-react"

    type Props = { regionId: string }

    const Region = ({ regionId }: Props) => { const deleteRegion = useAdminDeleteRegion(regionId) // ...

    const handleDelete = () => { deleteRegion.mutate(void 0, { onSuccess: ({ id, object, deleted }) => { console.log(id) } }) }

    // ... }

    export default Region

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/regions/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Regions

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminRegionsDeleteRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Region) Get

func (m *Region) Get(context fiber.Ctx) error

@oas:path [get] /admin/regions/{id} operationId: "GetRegionsRegion" summary: "Get a Region" description: "Retrieve a Region's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Region.

x-codegen:

method: 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.regions.retrieve(regionId) .then(({ region }) => { console.log(region.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminRegion } from "medusa-react"

    type Props = { regionId: string }

    const Region = ({ regionId }: Props) => { const { region, isLoading } = useAdminRegion( regionId )

    return ( <div> {isLoading && <span>Loading...</span>} {region && <span>{region.name}</span>} </div> ) }

    export default Region

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/regions/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Regions

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminRegionsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Region) GetFulfillmentOptions

func (m *Region) GetFulfillmentOptions(context fiber.Ctx) error

@oas:path [get] /admin/regions/{id}/fulfillment-options operationId: "GetRegionsRegionFulfillmentOptions" summary: "List Fulfillment Options" description: "Retrieve a list of fulfillment options available in a Region." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Region.

x-codegen:

method: retrieveFulfillmentOptions

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.regions.retrieveFulfillmentOptions(regionId) .then(({ fulfillment_options }) => { console.log(fulfillment_options.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminRegionFulfillmentOptions } from "medusa-react"

    type Props = { regionId: string }

    const Region = ({ regionId }: Props) => { const { fulfillment_options, isLoading } = useAdminRegionFulfillmentOptions( regionId )

    return ( <div> {isLoading && <span>Loading...</span>} {fulfillment_options && !fulfillment_options.length && ( <span>No Regions</span> )} {fulfillment_options && fulfillment_options.length > 0 && ( <ul> {fulfillment_options.map((option) => ( <li key={option.provider_id}> {option.provider_id} </li> ))} </ul> )} </div> ) }

    export default Region

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/regions/{id}/fulfillment-options' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Regions

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminGetRegionsRegionFulfillmentOptionsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Region) List

func (m *Region) List(context fiber.Ctx) error

@oas:path [get] /admin/regions operationId: "GetRegions" summary: "List Regions" description: "Retrieve a list of Regions. The regions can be filtered by fields such as `created_at`. The regions can also be paginated." x-authenticated: true parameters:

  • (query) q {string} Term used to search regions' name.
  • (query) order {string} A field to sort-order the retrieved regions by.
  • in: query name: limit schema: type: integer default: 50 required: false description: Limit the number of regions returned.
  • in: query name: offset schema: type: integer default: 0 required: false description: The number of regions to skip when retrieving the regions.
  • in: query name: created_at required: false description: Filter by a creation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: updated_at required: false description: Filter by an update date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: deleted_at required: false description: Filter by a deletion date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date

x-codegen:

method: list
queryParams: AdminGetRegionsParams

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.regions.list() .then(({ regions, limit, offset, count }) => { console.log(regions.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminRegions } from "medusa-react"

    const Regions = () => { const { regions, isLoading } = useAdminRegions()

    return ( <div> {isLoading && <span>Loading...</span>} {regions && !regions.length && <span>No Regions</span>} {regions && regions.length > 0 && ( <ul> {regions.map((region) => ( <li key={region.id}>{region.name}</li> ))} </ul> )} </div> ) }

    export default Regions

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/regions' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Regions

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminRegionsListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Region) RemoveCountry

func (m *Region) RemoveCountry(context fiber.Ctx) error

@oas:path [delete] /admin/regions/{id}/countries/{country_code} operationId: "PostRegionsRegionCountriesCountry" summary: "Remove Country" x-authenticated: true description: "Remove a Country from the list of Countries in a Region. The country will still be available in the system, and it can be used in other regions." parameters:

  • (path) id=* {string} The ID of the Region.
  • in: path name: country_code description: The 2 character ISO code for the Country. required: true schema: type: string externalDocs: url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes description: See a list of codes.

x-codegen:

method: deleteCountry

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.regions.deleteCountry(regionId, "dk") .then(({ region }) => { console.log(region.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminRegionRemoveCountry } from "medusa-react"

    type Props = { regionId: string }

    const Region = ({ regionId }: Props) => { const removeCountry = useAdminRegionRemoveCountry(regionId) // ...

    const handleRemoveCountry = ( countryCode: string ) => { removeCountry.mutate(countryCode, { onSuccess: ({ region }) => { console.log(region.countries) } }) }

    // ... }

    export default Region

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/regions/{id}/countries/{country_code}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Regions

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminRegionsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Region) RemoveFullfilmentProvider

func (m *Region) RemoveFullfilmentProvider(context fiber.Ctx) error

@oas:path [delete] /admin/regions/{id}/fulfillment-providers/{provider_id} operationId: "PostRegionsRegionFulfillmentProvidersProvider" summary: "Remove Fulfillment Provider" description: "Remove a Fulfillment Provider from a Region. The fulfillment provider will still be available for usage in other regions." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Region.
  • (path) provider_id=* {string} The ID of the Fulfillment Provider.

x-codegen:

method: deleteFulfillmentProvider

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.regions.deleteFulfillmentProvider(regionId, "manual") .then(({ region }) => { console.log(region.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminRegionDeleteFulfillmentProvider } from "medusa-react"

    type Props = { regionId: string }

    const Region = ({ regionId }: Props) => { const removeFulfillmentProvider = useAdminRegionDeleteFulfillmentProvider(regionId) // ...

    const handleRemoveFulfillmentProvider = ( providerId: string ) => { removeFulfillmentProvider.mutate(providerId, { onSuccess: ({ region }) => { console.log(region.fulfillment_providers) } }) }

    // ... }

    export default Region

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/regions/{id}/fulfillment-providers/{provider_id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Regions

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminRegionsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Region) RemovePaymentProvider

func (m *Region) RemovePaymentProvider(context fiber.Ctx) error

@oas:path [delete] /admin/regions/{id}/payment-providers/{provider_id} operationId: "PostRegionsRegionPaymentProvidersProvider" summary: "Remove Payment Provider" description: "Remove a Payment Provider from a Region. The payment provider will still be available for usage in other regions." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Region.
  • (path) provider_id=* {string} The ID of the Payment Provider.

x-codegen:

method: deletePaymentProvider

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.regions.deletePaymentProvider(regionId, "manual") .then(({ region }) => { console.log(region.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminRegionDeletePaymentProvider } from "medusa-react"

    type Props = { regionId: string }

    const Region = ({ regionId }: Props) => { const removePaymentProvider = useAdminRegionDeletePaymentProvider(regionId) // ...

    const handleRemovePaymentProvider = ( providerId: string ) => { removePaymentProvider.mutate(providerId, { onSuccess: ({ region }) => { console.log(region.payment_providers) } }) }

    // ... }

    export default Region

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/regions/{id}/payment-providers/{provider_id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Regions

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminRegionsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Region) SetRoutes

func (m *Region) SetRoutes(router fiber.Router)

func (*Region) Update

func (m *Region) Update(context fiber.Ctx) error

@oas:path [post] /admin/regions/{id} operationId: "PostRegionsRegion" summary: "Update a Region" description: "Update a Region's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Region.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostRegionsRegionReq"

x-codegen:

method: update

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.regions.update(regionId, { name: "Europe" }) .then(({ region }) => { console.log(region.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateRegion } from "medusa-react"

    type Props = { regionId: string }

    const Region = ({ regionId }: Props) => { const updateRegion = useAdminUpdateRegion(regionId) // ...

    const handleUpdate = ( countries: string[] ) => { updateRegion.mutate({ countries, }, { onSuccess: ({ region }) => { console.log(region.id) } }) }

    // ... }

    export default Region

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/regions/{id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "name": "Europe" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Regions

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminRegionsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type Registry

type Registry interface {
	Session() *session.Store

	Middleware() *middlewares.Handler

	Validator() *validator.Validate

	//Services
	AnalyticsConfigService() *services.AnalyticsConfigService
	AuthService() *services.AuthService
	BatchJobService() *services.BatchJobService
	CartService() *services.CartService
	ClaimItemService() *services.ClaimItemService
	ClaimService() *services.ClaimService
	CsvParserService() *services.CsvParserService
	CurrencyService() *services.CurrencyService
	CustomShippingOptionService() *services.CustomShippingOptionService
	CustomerGroupService() *services.CustomerGroupService
	CustomerService() *services.CustomerService
	DiscountConditionService() *services.DiscountConditionService
	DiscountService() *services.DiscountService
	DraftOrderService() *services.DraftOrderService
	EventBus() *services.Bus
	DefaultFileService() *services.DefaultFileService
	FulfillmentProviderService() *services.FulfillmentProviderService
	FulfillmentService() *services.FulfillmentService
	GiftCardService() *services.GiftCardService
	IdempotencyKeyService() *services.IdempotencyKeyService
	InviteService() *services.InviteService
	LineItemAdjustmentService() *services.LineItemAdjustmentService
	LineItemService() *services.LineItemService
	NewTotalsService() *services.NewTotalsService
	NoteService() *services.NoteService
	NotificationService() *services.NotificationService
	OAuthService() *services.OAuthService
	OrderItemChangeService() *services.OrderItemChangeService
	OrderEditService() *services.OrderEditService
	OrderService() *services.OrderService
	PaymentCollectionService() *services.PaymentCollectionService
	PaymentProviderService() *services.PaymentProviderService
	PaymentService() *services.PaymentService
	PriceListService() *services.PriceListService
	PricingService() *services.PricingService
	ProductCategoryService() *services.ProductCategoryService
	ProductCollectionService() *services.ProductCollectionService
	ProductTagService() *services.ProductTagService
	ProductTaxRateService() *services.ProductTaxRateService
	ProductTypeService() *services.ProductTypeService
	ProductVariantInventoryService() *services.ProductVariantInventoryService
	ProductVariantService() *services.ProductVariantService
	ProductService() *services.ProductService
	PublishableApiKeyService() *services.PublishableApiKeyService
	RegionService() *services.RegionService
	ReturnReasonService() *services.ReturnReasonService
	ReturnService() *services.ReturnService
	SalesChannelInventoryService() *services.SalesChannelInventoryService
	SalesChannelLocationService() *services.SalesChannelLocationService
	SalesChannelService() *services.SalesChannelService
	DefaultSearchService() *services.DefaultSearchService
	ShippingOptionService() *services.ShippingOptionService
	ShippingProfileService() *services.ShippingProfileService
	ShippingTaxRateService() *services.ShippingTaxRateService
	StagedJobService() *services.StagedJobService
	StoreService() *services.StoreService
	StrategyResolverService() *services.StrategyResolverService
	SwapService() *services.SwapService
	SystemProviderService() *services.SystemProviderService
	SystemTaxService() *services.SystemTaxService
	TaxProviderService() *services.TaxProviderService
	TaxRateService() *services.TaxRateService
	TockenService() *services.TockenService
	TotalsService() *services.TotalsService
	UserService() *services.UserService

	//Interfaces
	PriceSelectionStrategy() interfaces.IPriceSelectionStrategy
	TaxCalculationStrategy() interfaces.ITaxCalculationStrategy
	InventoryService() interfaces.IInventoryService
	StockLocationService() interfaces.IStockLocationService
	CacheService() interfaces.ICacheService
	PricingModuleService() interfaces.IPricingModuleService
	FileService() interfaces.IFileService
}

type Reservation

type Reservation struct {
	// contains filtered or unexported fields
}

func NewReservation

func NewReservation(r Registry) *Reservation

func (*Reservation) Create

func (m *Reservation) Create(context fiber.Ctx) error

func (*Reservation) Delete

func (m *Reservation) Delete(context fiber.Ctx) error

func (*Reservation) Get

func (m *Reservation) Get(context fiber.Ctx) error

func (*Reservation) List

func (m *Reservation) List(context fiber.Ctx) error

func (*Reservation) SetRoutes

func (m *Reservation) SetRoutes(router fiber.Router)

func (*Reservation) Update

func (m *Reservation) Update(context fiber.Ctx) error

type ResponseInventoryItem

type ResponseInventoryItem struct {
	interfaces.InventoryItemDTO
	LocationLevels   []interfaces.InventoryLevelDTO `json:"location_levels,omitempty"`
	StockedQuantity  int
	ReservedQuantity int
}

type Return

type Return struct {
	// contains filtered or unexported fields
}

func NewReturn

func NewReturn(r Registry) *Return

func (*Return) Cancel

func (m *Return) Cancel(context fiber.Ctx) error

@oas:path [post] /admin/returns/{id}/cancel operationId: "PostReturnsReturnCancel" summary: "Cancel a Return" description: "Registers a Return as canceled. The return can be associated with an order, claim, or swap." parameters:

  • (path) id=* {string} The ID of the Return.

x-codegen:

method: cancel

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.returns.cancel(returnId) .then(({ order }) => { console.log(order.id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCancelReturn } from "medusa-react"

    type Props = { returnId: string }

    const Return = ({ returnId }: Props) => { const cancelReturn = useAdminCancelReturn( returnId ) // ...

    const handleCancel = () => { cancelReturn.mutate(void 0, { onSuccess: ({ order }) => { console.log(order.returns) } }) }

    // ... }

    export default Return

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/returns/{id}/cancel' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Returns

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminReturnsCancelRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Return) List

func (m *Return) List(context fiber.Ctx) error

@oas:path [get] /admin/returns operationId: "GetReturns" summary: "List Returns" description: "Retrieve a list of Returns. The returns can be paginated." parameters:

  • (query) limit=50 {number} Limit the number of Returns returned.
  • (query) offset=0 {number} The number of Returns to skip when retrieving the Returns.

x-codegen:

method: list
queryParams: AdminGetReturnsParams

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.returns.list() .then(({ returns, limit, offset, count }) => { console.log(returns.length) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminReturns } from "medusa-react"

    const Returns = () => { const { returns, isLoading } = useAdminReturns()

    return ( <div> {isLoading && <span>Loading...</span>} {returns && !returns.length && ( <span>No Returns</span> )} {returns && returns.length > 0 && ( <ul> {returns.map((returnData) => ( <li key={returnData.id}> {returnData.status} </li> ))} </ul> )} </div> ) }

    export default Returns

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/returns' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Returns

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminReturnsListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Return) Receive

func (m *Return) Receive(context fiber.Ctx) error

@oas:path [post] /admin/returns/{id}/receive operationId: "PostReturnsReturnReceive" summary: "Receive a Return" description: "Mark a Return as received. This also updates the status of associated order, claim, or swap accordingly." parameters:

  • (path) id=* {string} The ID of the Return.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostReturnsReturnReceiveReq"

x-codegen:

method: receive

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.returns.receive(returnId, { items: [ { item_id, quantity: 1 } ] }) .then((data) => { console.log(data.return.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminReceiveReturn } from "medusa-react"

    type ReceiveReturnData = { items: { item_id: string quantity: number }[] }

    type Props = { returnId: string }

    const Return = ({ returnId }: Props) => { const receiveReturn = useAdminReceiveReturn( returnId ) // ...

    const handleReceive = (data: ReceiveReturnData) => { receiveReturn.mutate(data, { onSuccess: ({ return: dataReturn }) => { console.log(dataReturn.status) } }) }

    // ... }

    export default Return

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/returns/{id}/receive' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "items": [ { "item_id": "asafg", "quantity": 1 } ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Returns

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminReturnsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Return) SetRoutes

func (m *Return) SetRoutes(router fiber.Router)

type ReturnReason

type ReturnReason struct {
	// contains filtered or unexported fields
}

func NewReturnReason

func NewReturnReason(r Registry) *ReturnReason

func (*ReturnReason) Create

func (m *ReturnReason) Create(context fiber.Ctx) error

@oas:path [post] /admin/return-reasons operationId: "PostReturnReasons" summary: "Create a Return Reason" description: "Create a Return Reason." x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostReturnReasonsReq"

x-codegen:

method: 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.returnReasons.create({ label: "Damaged", value: "damaged" }) .then(({ return_reason }) => { console.log(return_reason.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateReturnReason } from "medusa-react"

    const CreateReturnReason = () => { const createReturnReason = useAdminCreateReturnReason() // ...

    const handleCreate = ( label: string, value: string ) => { createReturnReason.mutate({ label, value, }, { onSuccess: ({ return_reason }) => { console.log(return_reason.id) } }) }

    // ... }

    export default CreateReturnReason

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/return-reasons' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "label": "Damaged", "value": "damaged" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Return Reasons

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminReturnReasonsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*ReturnReason) Delete

func (m *ReturnReason) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/return-reasons/{id} operationId: "DeleteReturnReason" summary: "Delete a Return Reason" description: "Delete a return reason." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the return reason

x-codegen:

method: 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.returnReasons.delete(returnReasonId) .then(({ id, object, deleted }) => { console.log(id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteReturnReason } from "medusa-react"

    type Props = { returnReasonId: string }

    const ReturnReason = ({ returnReasonId }: Props) => { const deleteReturnReason = useAdminDeleteReturnReason( returnReasonId ) // ...

    const handleDelete = () => { deleteReturnReason.mutate(void 0, { onSuccess: ({ id, object, deleted }) => { console.log(id) } }) }

    // ... }

    export default ReturnReason

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/return-reasons/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Return Reasons

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminReturnReasonsDeleteRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*ReturnReason) Get

func (m *ReturnReason) Get(context fiber.Ctx) error

@oas:path [get] /admin/return-reasons/{id} operationId: "GetReturnReasonsReason" summary: "Get a Return Reason" description: "Retrieve a Return Reason's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Return Reason.

x-codegen:

method: 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.returnReasons.retrieve(returnReasonId) .then(({ return_reason }) => { console.log(return_reason.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminReturnReason } from "medusa-react"

    type Props = { returnReasonId: string }

    const ReturnReason = ({ returnReasonId }: Props) => { const { return_reason, isLoading } = useAdminReturnReason( returnReasonId )

    return ( <div> {isLoading && <span>Loading...</span>} {return_reason && <span>{return_reason.label}</span>} </div> ) }

    export default ReturnReason

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/return-reasons/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Return Reasons

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminReturnReasonsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*ReturnReason) List

func (m *ReturnReason) List(context fiber.Ctx) error

@oas:path [get] /admin/return-reasons operationId: "GetReturnReasons" summary: "List Return Reasons" description: "Retrieve a list of Return Reasons." x-authenticated: true x-codegen:

method: list

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.returnReasons.list() .then(({ return_reasons }) => { console.log(return_reasons.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminReturnReasons } from "medusa-react"

    const ReturnReasons = () => { const { return_reasons, isLoading } = useAdminReturnReasons()

    return ( <div> {isLoading && <span>Loading...</span>} {return_reasons && !return_reasons.length && ( <span>No Return Reasons</span> )} {return_reasons && return_reasons.length > 0 && ( <ul> {return_reasons.map((reason) => ( <li key={reason.id}> {reason.label}: {reason.value} </li> ))} </ul> )} </div> ) }

    export default ReturnReasons

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/return-reasons' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Return Reasons

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminReturnReasonsListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*ReturnReason) SetRoutes

func (m *ReturnReason) SetRoutes(router fiber.Router)

func (*ReturnReason) Update

func (m *ReturnReason) Update(context fiber.Ctx) error

@oas:path [post] /admin/return-reasons/{id} operationId: "PostReturnReasonsReason" summary: "Update a Return Reason" description: "Update a Return Reason's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Return Reason.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostReturnReasonsReasonReq"

x-codegen:

method: update

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.returnReasons.update(returnReasonId, { label: "Damaged" }) .then(({ return_reason }) => { console.log(return_reason.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateReturnReason } from "medusa-react"

    type Props = { returnReasonId: string }

    const ReturnReason = ({ returnReasonId }: Props) => { const updateReturnReason = useAdminUpdateReturnReason( returnReasonId ) // ...

    const handleUpdate = ( label: string ) => { updateReturnReason.mutate({ label, }, { onSuccess: ({ return_reason }) => { console.log(return_reason.label) } }) }

    // ... }

    export default ReturnReason

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/return-reasons/{id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "label": "Damaged" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Return Reasons

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminReturnReasonsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type SalesChannel

type SalesChannel struct {
	// contains filtered or unexported fields
}

func NewSalesChannel

func NewSalesChannel(r Registry) *SalesChannel

func (*SalesChannel) AddProductsBatch

func (m *SalesChannel) AddProductsBatch(context fiber.Ctx) error

@oas:path [post] /admin/sales-channels/{id}/products/batch operationId: "PostSalesChannelsChannelProductsBatch" summary: "Add Products to Sales Channel" description: "Add a list of products to a sales channel." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Sales channel.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostSalesChannelsChannelProductsBatchReq"

x-codegen:

method: addProducts

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.salesChannels.addProducts(salesChannelId, { product_ids: [ { id: productId } ] }) .then(({ sales_channel }) => { console.log(sales_channel.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminAddProductsToSalesChannel } from "medusa-react"

    type Props = { salesChannelId: string }

    const SalesChannel = ({ salesChannelId }: Props) => { const addProducts = useAdminAddProductsToSalesChannel( salesChannelId ) // ...

    const handleAddProducts = (productId: string) => { addProducts.mutate({ product_ids: [ { id: productId, }, ], }, { onSuccess: ({ sales_channel }) => { console.log(sales_channel.id) } }) }

    // ... }

    export default SalesChannel

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/sales-channels/{id}/products/batch' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "product_ids": [ { "id": "{product_id}" } ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Sales Channels

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminSalesChannelsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*SalesChannel) AddStockLocation

func (m *SalesChannel) AddStockLocation(context fiber.Ctx) error

@oas:path [post] /admin/sales-channels/{id}/stock-locations operationId: "PostSalesChannelsSalesChannelStockLocation" summary: "Associate a Stock Location" description: "Associate a stock location with a Sales Channel." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Sales Channel.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostSalesChannelsChannelStockLocationsReq"

x-codegen:

method: addLocation

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.salesChannels.addLocation(salesChannelId, { location_id: "loc_123" }) .then(({ sales_channel }) => { console.log(sales_channel.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminAddLocationToSalesChannel } from "medusa-react"

    type Props = { salesChannelId: string }

    const SalesChannel = ({ salesChannelId }: Props) => { const addLocation = useAdminAddLocationToSalesChannel() // ...

    const handleAddLocation = (locationId: string) => { addLocation.mutate({ sales_channel_id: salesChannelId, location_id: locationId }, { onSuccess: ({ sales_channel }) => { console.log(sales_channel.locations) } }) }

    // ... }

    export default SalesChannel

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/sales-channels/{id}/stock-locations' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "locaton_id": "loc_123" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Sales Channels

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminSalesChannelsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*SalesChannel) Create

func (m *SalesChannel) Create(context fiber.Ctx) error

@oas:path [post] /admin/sales-channels operationId: "PostSalesChannels" summary: "Create a Sales Channel" description: "Create a Sales Channel." x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostSalesChannelsReq"

x-codegen:

method: 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.salesChannels.create({ name: "App", description: "Mobile app" }) .then(({ sales_channel }) => { console.log(sales_channel.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateSalesChannel } from "medusa-react"

    const CreateSalesChannel = () => { const createSalesChannel = useAdminCreateSalesChannel() // ...

    const handleCreate = (name: string, description: string) => { createSalesChannel.mutate({ name, description, }, { onSuccess: ({ sales_channel }) => { console.log(sales_channel.id) } }) }

    // ... }

    export default CreateSalesChannel

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/sales-channels' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "name": "App" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Sales Channels

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminSalesChannelsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*SalesChannel) Delete

func (m *SalesChannel) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/sales-channels/{id} operationId: "DeleteSalesChannelsSalesChannel" summary: "Delete a Sales Channel" description: "Delete a sales channel. Associated products, stock locations, and other resources are not deleted." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Sales channel.

x-codegen:

method: 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.salesChannels.delete(salesChannelId) .then(({ id, object, deleted }) => { console.log(id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteSalesChannel } from "medusa-react"

    type Props = { salesChannelId: string }

    const SalesChannel = ({ salesChannelId }: Props) => { const deleteSalesChannel = useAdminDeleteSalesChannel( salesChannelId ) // ...

    const handleDelete = () => { deleteSalesChannel.mutate(void 0, { onSuccess: ({ id, object, deleted }) => { console.log(id) } }) }

    // ... }

    export default SalesChannel

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/sales-channels/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Sales Channels

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminSalesChannelsDeleteRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*SalesChannel) DeleteProductsBatch

func (m *SalesChannel) DeleteProductsBatch(context fiber.Ctx) error

@oas:path [delete] /admin/sales-channels/{id}/products/batch operationId: "DeleteSalesChannelsChannelProductsBatch" summary: "Remove Products from Sales Channel" description: "Remove a list of products from a sales channel. This does not delete the product. It only removes the association between the product and the sales channel." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Sales Channel

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminDeleteSalesChannelsChannelProductsBatchReq"

x-codegen:

method: removeProducts

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.salesChannels.removeProducts(salesChannelId, { product_ids: [ { id: productId } ] }) .then(({ sales_channel }) => { console.log(sales_channel.id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteProductsFromSalesChannel, } from "medusa-react"

    type Props = { salesChannelId: string }

    const SalesChannel = ({ salesChannelId }: Props) => { const deleteProducts = useAdminDeleteProductsFromSalesChannel( salesChannelId ) // ...

    const handleDeleteProducts = (productId: string) => { deleteProducts.mutate({ product_ids: [ { id: productId, }, ], }, { onSuccess: ({ sales_channel }) => { console.log(sales_channel.id) } }) }

    // ... }

    export default SalesChannel

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/sales-channels/{id}/products/batch' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "product_ids": [ { "id": "{product_id}" } ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Sales Channels

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminSalesChannelsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*SalesChannel) Get

func (m *SalesChannel) Get(context fiber.Ctx) error

@oas:path [get] /admin/sales-channels/{id} operationId: "GetSalesChannelsSalesChannel" summary: "Get a Sales Channel" description: "Retrieve a sales channel's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Sales channel.

x-codegen:

method: 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.salesChannels.retrieve(salesChannelId) .then(({ sales_channel }) => { console.log(sales_channel.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminSalesChannel } from "medusa-react"

    type Props = { salesChannelId: string }

    const SalesChannel = ({ salesChannelId }: Props) => { const { sales_channel, isLoading, } = useAdminSalesChannel(salesChannelId)

    return ( <div> {isLoading && <span>Loading...</span>} {sales_channel && <span>{sales_channel.name}</span>} </div> ) }

    export default SalesChannel

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/sales-channels/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Sales Channels

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminSalesChannelsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*SalesChannel) List

func (m *SalesChannel) List(context fiber.Ctx) error

@oas:path [get] /admin/sales-channels operationId: "GetSalesChannels" summary: "List Sales Channels" description: "Retrieve a list of sales channels. The sales channels can be filtered by fields such as `q` or `name`. The sales channels can also be sorted or paginated." x-authenticated: true parameters:

  • (query) id {string} Filter by a sales channel ID.
  • (query) name {string} Filter by name.
  • (query) description {string} Filter by description.
  • (query) q {string} term used to search sales channels' names and descriptions.
  • (query) order {string} A sales-channel field to sort-order the retrieved sales channels by.
  • in: query name: created_at description: Filter by a creation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: updated_at description: Filter by an update date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: deleted_at description: Filter by a deletion date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • (query) offset=0 {integer} The number of sales channels to skip when retrieving the sales channels.
  • (query) limit=20 {integer} Limit the number of sales channels returned.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned sales channels.
  • (query) fields {string} Comma-separated fields that should be included in the returned sales channels.

x-codegen:

method: list
queryParams: AdminGetSalesChannelsParams

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.salesChannels.list() .then(({ sales_channels, limit, offset, count }) => { console.log(sales_channels.length) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminSalesChannels } from "medusa-react"

    const SalesChannels = () => { const { sales_channels, isLoading } = useAdminSalesChannels()

    return ( <div> {isLoading && <span>Loading...</span>} {sales_channels && !sales_channels.length && ( <span>No Sales Channels</span> )} {sales_channels && sales_channels.length > 0 && ( <ul> {sales_channels.map((salesChannel) => ( <li key={salesChannel.id}>{salesChannel.name}</li> ))} </ul> )} </div> ) }

    export default SalesChannels

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/sales-channels' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Sales Channels

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminSalesChannelsListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*SalesChannel) RemoveStockLocation

func (m *SalesChannel) RemoveStockLocation(context fiber.Ctx) error

@oas:path [delete] /admin/sales-channels/{id}/stock-locations operationId: "DeleteSalesChannelsSalesChannelStockLocation" summary: "Remove Stock Location from Sales Channels." description: "Remove a stock location from a Sales Channel. This only removes the association between the stock location and the sales channel. It does not delete the stock location." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Sales Channel.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminDeleteSalesChannelsChannelStockLocationsReq"

x-codegen:

method: removeLocation

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.salesChannels.removeLocation(salesChannelId, { location_id: "loc_id" }) .then(({ sales_channel }) => { console.log(sales_channel.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminRemoveLocationFromSalesChannel } from "medusa-react"

    type Props = { salesChannelId: string }

    const SalesChannel = ({ salesChannelId }: Props) => { const removeLocation = useAdminRemoveLocationFromSalesChannel() // ...

    const handleRemoveLocation = (locationId: string) => { removeLocation.mutate({ sales_channel_id: salesChannelId, location_id: locationId }, { onSuccess: ({ sales_channel }) => { console.log(sales_channel.locations) } }) }

    // ... }

    export default SalesChannel

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/sales-channels/{id}/stock-locations' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "locaton_id": "loc_id" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Sales Channels

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminSalesChannelsDeleteLocationRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*SalesChannel) SetRoutes

func (m *SalesChannel) SetRoutes(router fiber.Router)

func (*SalesChannel) Update

func (m *SalesChannel) Update(context fiber.Ctx) error

@oas:path [post] /admin/sales-channels/{id} operationId: "PostSalesChannelsSalesChannel" summary: "Update a Sales Channel" description: "Update a Sales Channel's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Sales Channel.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostSalesChannelsSalesChannelReq"

x-codegen:

method: update

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.salesChannels.update(salesChannelId, { name: "App" }) .then(({ sales_channel }) => { console.log(sales_channel.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateSalesChannel } from "medusa-react"

    type Props = { salesChannelId: string }

    const SalesChannel = ({ salesChannelId }: Props) => { const updateSalesChannel = useAdminUpdateSalesChannel( salesChannelId ) // ...

    const handleUpdate = ( is_disabled: boolean ) => { updateSalesChannel.mutate({ is_disabled, }, { onSuccess: ({ sales_channel }) => { console.log(sales_channel.is_disabled) } }) }

    // ... }

    export default SalesChannel

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/sales-channels/{id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "name": "App" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Sales Channels

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminSalesChannelsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type SalesChannelAvailability

type SalesChannelAvailability struct {
	ChannelId         uuid.UUID `json:"channel_id"`
	ChannelName       string    `json:"channel_name"`
	AvailableQuantity int       `json:"available_quantity"`
}

type ShippingOption

type ShippingOption struct {
	// contains filtered or unexported fields
}

func NewShippingOption

func NewShippingOption(r Registry) *ShippingOption

func (*ShippingOption) Create

func (m *ShippingOption) Create(context fiber.Ctx) error

@oas:path [post] /admin/shipping-options operationId: "PostShippingOptions" summary: "Create Shipping Option" description: "Create a Shipping Option." x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostShippingOptionsReq"

x-codegen:

method: 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.shippingOptions.create({ name: "PostFake", region_id, provider_id, data: { }, price_type: "flat_rate" }) .then(({ shipping_option }) => { console.log(shipping_option.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateShippingOption } from "medusa-react"

    type CreateShippingOption = { name: string provider_id: string data: Record<string, unknown> price_type: string amount: number }

    type Props = { regionId: string }

    const Region = ({ regionId }: Props) => { const createShippingOption = useAdminCreateShippingOption() // ...

    const handleCreate = ( data: CreateShippingOption ) => { createShippingOption.mutate({ ...data, region_id: regionId }, { onSuccess: ({ shipping_option }) => { console.log(shipping_option.id) } }) }

    // ... }

    export default Region

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/shipping-options' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "name": "PostFake", "region_id": "afasf", "provider_id": "manual", "data": {}, "price_type": "flat_rate" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Shipping Options

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminShippingOptionsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*ShippingOption) Delete

func (m *ShippingOption) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/shipping-options/{id} operationId: "DeleteShippingOptionsOption" summary: "Delete Shipping Option" description: "Delete a Shipping Option. Once deleted, it can't be used when creating orders or returns." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Shipping Option.

x-codegen:

method: 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.shippingOptions.delete(optionId) .then(({ id, object, deleted }) => { console.log(id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteShippingOption } from "medusa-react"

    type Props = { shippingOptionId: string }

    const ShippingOption = ({ shippingOptionId }: Props) => { const deleteShippingOption = useAdminDeleteShippingOption( shippingOptionId ) // ...

    const handleDelete = () => { deleteShippingOption.mutate(void 0, { onSuccess: ({ id, object, deleted }) => { console.log(id) } }) }

    // ... }

    export default ShippingOption

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/shipping-options/{option_id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Shipping Options

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminShippingOptionsDeleteRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*ShippingOption) Get

func (m *ShippingOption) Get(context fiber.Ctx) error

@oas:path [get] /admin/shipping-options/{id} operationId: "GetShippingOptionsOption" summary: "Get a Shipping Option" description: "Retrieve a Shipping Option's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Shipping Option.

x-codegen:

method: 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.shippingOptions.retrieve(optionId) .then(({ shipping_option }) => { console.log(shipping_option.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminShippingOption } from "medusa-react"

    type Props = { shippingOptionId: string }

    const ShippingOption = ({ shippingOptionId }: Props) => { const { shipping_option, isLoading } = useAdminShippingOption( shippingOptionId )

    return ( <div> {isLoading && <span>Loading...</span>} {shipping_option && <span>{shipping_option.name}</span>} </div> ) }

    export default ShippingOption

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/shipping-options/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Shipping Options

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminShippingOptionsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*ShippingOption) List

func (m *ShippingOption) List(context fiber.Ctx) error

@oas:path [get] /admin/shipping-options operationId: "GetShippingOptions" summary: "List Shipping Options" description: "Retrieve a list of Shipping Options. The shipping options can be filtered by fields such as `region_id` or `is_return`. The shipping options can also be sorted or paginated." x-authenticated: true parameters:

  • (query) name {string} Filter by name.
  • (query) region_id {string} Filter by the ID of the region the shipping options belong to.
  • (query) is_return {boolean} Filter by whether the shipping options are return shipping options.
  • (query) admin_only {boolean} Filter by whether the shipping options are available for admin users only.
  • (query) q {string} Term used to search shipping options' name.
  • (query) order {string} A shipping option field to sort-order the retrieved shipping options by.
  • in: query name: id style: form explode: false description: Filter by shipping option IDs. schema: oneOf:
  • type: string description: ID of the shipping option.
  • type: array items: type: string description: ID of a shipping option.
  • in: query name: created_at description: Filter by a creation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: updated_at description: Filter by an update date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: deleted_at description: Filter by a deletion date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • (query) offset=0 {integer} The number of users to skip when retrieving the shipping options.
  • (query) limit=20 {integer} Limit the number of shipping options returned.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned shipping options.
  • (query) fields {string} Comma-separated fields that should be included in the returned shipping options.

x-codegen:

method: list
queryParams: AdminGetShippingOptionsParams

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.shippingOptions.list() .then(({ shipping_options, count }) => { console.log(shipping_options.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminShippingOptions } from "medusa-react"

    const ShippingOptions = () => { const { shipping_options, isLoading } = useAdminShippingOptions()

    return ( <div> {isLoading && <span>Loading...</span>} {shipping_options && !shipping_options.length && ( <span>No Shipping Options</span> )} {shipping_options && shipping_options.length > 0 && ( <ul> {shipping_options.map((option) => ( <li key={option.id}>{option.name}</li> ))} </ul> )} </div> ) }

    export default ShippingOptions

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/shipping-options' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Shipping Options

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminShippingOptionsListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*ShippingOption) SetRoutes

func (m *ShippingOption) SetRoutes(router fiber.Router)

func (*ShippingOption) Update

func (m *ShippingOption) Update(context fiber.Ctx) error

@oas:path [post] /admin/shipping-options/{id} operationId: "PostShippingOptionsOption" summary: "Update Shipping Option" description: "Update a Shipping Option's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Shipping Option.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostShippingOptionsOptionReq"

x-codegen:

method: update

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.shippingOptions.update(optionId, { name: "PostFake", requirements: [ { id, type: "max_subtotal", amount: 1000 } ] }) .then(({ shipping_option }) => { console.log(shipping_option.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateShippingOption } from "medusa-react"

    type Props = { shippingOptionId: string }

    const ShippingOption = ({ shippingOptionId }: Props) => { const updateShippingOption = useAdminUpdateShippingOption( shippingOptionId ) // ...

    const handleUpdate = ( name: string, requirements: { id: string, type: string, amount: number }[] ) => { updateShippingOption.mutate({ name, requirements }, { onSuccess: ({ shipping_option }) => { console.log(shipping_option.requirements) } }) }

    // ... }

    export default ShippingOption

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/shipping-options/{id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "requirements": [ { "type": "max_subtotal", "amount": 1000 } ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Shipping Options

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminShippingOptionsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type ShippingProfile

type ShippingProfile struct {
	// contains filtered or unexported fields
}

func NewShippingProfile

func NewShippingProfile(r Registry) *ShippingProfile

func (*ShippingProfile) Create

func (m *ShippingProfile) Create(context fiber.Ctx) error

@oas:path [post] /admin/shipping-profiles operationId: "PostShippingProfiles" summary: "Create a Shipping Profile" description: "Create a Shipping Profile." x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostShippingProfilesReq"

x-codegen:

method: 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.shippingProfiles.create({ name: "Large Products" }) .then(({ shipping_profile }) => { console.log(shipping_profile.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { ShippingProfileType } from "@medusajs/medusa" import { useAdminCreateShippingProfile } from "medusa-react"

    const CreateShippingProfile = () => { const createShippingProfile = useAdminCreateShippingProfile() // ...

    const handleCreate = ( name: string, type: ShippingProfileType ) => { createShippingProfile.mutate({ name, type }, { onSuccess: ({ shipping_profile }) => { console.log(shipping_profile.id) } }) }

    // ... }

    export default CreateShippingProfile

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/shipping-profiles' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "name": "Large Products" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Shipping Profiles

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminShippingProfilesRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*ShippingProfile) Delete

func (m *ShippingProfile) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/shipping-profiles/{id} operationId: "DeleteShippingProfilesProfile" summary: "Delete a Shipping Profile" description: "Delete a Shipping Profile. Associated shipping options are deleted as well." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Shipping Profile.

x-codegen:

method: 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.shippingProfiles.delete(profileId) .then(({ id, object, deleted }) => { console.log(id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteShippingProfile } from "medusa-react"

    type Props = { shippingProfileId: string }

    const ShippingProfile = ({ shippingProfileId }: Props) => { const deleteShippingProfile = useAdminDeleteShippingProfile( shippingProfileId ) // ...

    const handleDelete = () => { deleteShippingProfile.mutate(void 0, { onSuccess: ({ id, object, deleted }) => { console.log(id) } }) }

    // ... }

    export default ShippingProfile

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/shipping-profiles/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Shipping Profiles

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDeleteShippingProfileRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*ShippingProfile) Get

func (m *ShippingProfile) Get(context fiber.Ctx) error

@oas:path [get] /admin/shipping-profiles/{id} operationId: "GetShippingProfilesProfile" summary: "Get a Shipping Profile" description: "Retrieve a Shipping Profile's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Shipping Profile.

x-codegen:

method: 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.shippingProfiles.retrieve(profileId) .then(({ shipping_profile }) => { console.log(shipping_profile.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminShippingProfile } from "medusa-react"

    type Props = { shippingProfileId: string }

    const ShippingProfile = ({ shippingProfileId }: Props) => { const { shipping_profile, isLoading } = useAdminShippingProfile( shippingProfileId )

    return ( <div> {isLoading && <span>Loading...</span>} {shipping_profile && ( <span>{shipping_profile.name}</span> )} </div> ) }

    export default ShippingProfile

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/shipping-profiles/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Shipping Profiles

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminShippingProfilesRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*ShippingProfile) List

func (m *ShippingProfile) List(context fiber.Ctx) error

@oas:path [get] /admin/shipping-profiles operationId: "GetShippingProfiles" summary: "List Shipping Profiles" description: "Retrieve a list of Shipping Profiles." x-authenticated: true x-codegen:

method: list

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.shippingProfiles.list() .then(({ shipping_profiles }) => { console.log(shipping_profiles.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminShippingProfiles } from "medusa-react"

    const ShippingProfiles = () => { const { shipping_profiles, isLoading } = useAdminShippingProfiles()

    return ( <div> {isLoading && <span>Loading...</span>} {shipping_profiles && !shipping_profiles.length && ( <span>No Shipping Profiles</span> )} {shipping_profiles && shipping_profiles.length > 0 && ( <ul> {shipping_profiles.map((profile) => ( <li key={profile.id}>{profile.name}</li> ))} </ul> )} </div> ) }

    export default ShippingProfiles

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/shipping-profiles' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Shipping Profiles

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminShippingProfilesListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*ShippingProfile) SetRoutes

func (m *ShippingProfile) SetRoutes(router fiber.Router)

func (*ShippingProfile) Update

func (m *ShippingProfile) Update(context fiber.Ctx) error

@oas:path [post] /admin/shipping-profiles/{id} operationId: "PostShippingProfilesProfile" summary: "Update a Shipping Profile" description: "Update a Shipping Profile's details." parameters:

  • (path) id=* {string} The ID of the Shipping Profile.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostShippingProfilesProfileReq"

x-codegen:

method: update

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.shippingProfiles.update(shippingProfileId, { name: 'Large Products' }) .then(({ shipping_profile }) => { console.log(shipping_profile.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { ShippingProfileType } from "@medusajs/medusa" import { useAdminUpdateShippingProfile } from "medusa-react"

    type Props = { shippingProfileId: string }

    const ShippingProfile = ({ shippingProfileId }: Props) => { const updateShippingProfile = useAdminUpdateShippingProfile( shippingProfileId ) // ...

    const handleUpdate = ( name: string, type: ShippingProfileType ) => { updateShippingProfile.mutate({ name, type }, { onSuccess: ({ shipping_profile }) => { console.log(shipping_profile.name) } }) }

    // ... }

    export default ShippingProfile

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/shipping-profiles/{id} \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "name": "Large Products" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Shipping Profiles

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminShippingProfilesRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type StockLocation

type StockLocation struct {
	// contains filtered or unexported fields
}

func NewStockLocation

func NewStockLocation(r Registry) *StockLocation

func (*StockLocation) Create

func (m *StockLocation) Create(context fiber.Ctx) error

@oas:path [post] /admin/stock-locations operationId: "PostStockLocations" summary: "Create a Stock Location" description: "Create a Stock Location." x-authenticated: true parameters:

  • (query) expand {string} Comma-separated relations that should be expanded in the returned stock location.
  • (query) fields {string} Comma-separated fields that should be included in the returned stock location.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostStockLocationsReq"

x-codegen:

method: 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.stockLocations.create({ name: "Main Warehouse", }) .then(({ stock_location }) => { console.log(stock_location.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateStockLocation } from "medusa-react"

    const CreateStockLocation = () => { const createStockLocation = useAdminCreateStockLocation() // ...

    const handleCreate = (name: string) => { createStockLocation.mutate({ name, }, { onSuccess: ({ stock_location }) => { console.log(stock_location.id) } }) }

    // ... }

    export default CreateStockLocation

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/stock-locations' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "name": "App" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Stock Locations

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminStockLocationsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*StockLocation) Delete

func (m *StockLocation) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/stock-locations/{id} operationId: "DeleteStockLocationsStockLocation" summary: "Delete a Stock Location" description: "Delete a Stock Location." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Stock Location.

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.stockLocations.delete(stockLocationId) .then(({ id, object, deleted }) => { console.log(id) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteStockLocation } from "medusa-react"

    type Props = { stockLocationId: string }

    const StockLocation = ({ stockLocationId }: Props) => { const deleteLocation = useAdminDeleteStockLocation( stockLocationId ) // ...

    const handleDelete = () => { deleteLocation.mutate(void 0, { onSuccess: ({ id, object, deleted }) => { console.log(id) } }) } }

    export default StockLocation

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/stock-locations/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Stock Locations

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminStockLocationsDeleteRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"

func (*StockLocation) Get

func (m *StockLocation) Get(context fiber.Ctx) error

@oas:path [get] /admin/stock-locations/{id} operationId: "GetStockLocationsStockLocation" summary: "Get a Stock Location" description: "Retrieve a Stock Location's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Stock Location.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned stock location.
  • (query) fields {string} Comma-separated fields that should be included in the returned stock location.

x-codegen:

method: retrieve
queryParams: AdminGetStockLocationsLocationParams

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.stockLocations.retrieve(stockLocationId) .then(({ stock_location }) => { console.log(stock_location.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminStockLocation } from "medusa-react"

    type Props = { stockLocationId: string }

    const StockLocation = ({ stockLocationId }: Props) => { const { stock_location, isLoading } = useAdminStockLocation(stockLocationId)

    return ( <div> {isLoading && <span>Loading...</span>} {stock_location && ( <span>{stock_location.name}</span> )} </div> ) }

    export default StockLocation

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/stock-locations/{id}' \ -H 'x-medusa-access-token: "{api_token}"' \

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Stock Locations

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminStockLocationsRes"

func (*StockLocation) List

func (m *StockLocation) List(context fiber.Ctx) error

@oas:path [get] /admin/stock-locations operationId: "GetStockLocations" summary: "List Stock Locations" description: "Retrieve a list of stock locations. The stock locations can be filtered by fields such as `name` or `created_at`. The stock locations can also be sorted or paginated." x-authenticated: true parameters:

  • (query) id {string} Filter by ID.
  • (query) name {string} Filter by name.
  • (query) order {string} A stock-location field to sort-order the retrieved stock locations by.
  • in: query name: created_at description: Filter by a creation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: updated_at description: Filter by an update date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: deleted_at description: Filter by a deletion date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • (query) offset=0 {integer} The number of stock locations to skip when retrieving the stock locations.
  • (query) limit=20 {integer} Limit the number of stock locations returned.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned stock locations.
  • (query) fields {string} Comma-separated fields that should be included in the returned stock locations.

x-codegen:

method: list
queryParams: AdminGetStockLocationsParams

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.stockLocations.list() .then(({ stock_locations, limit, offset, count }) => { console.log(stock_locations.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminStockLocations } from "medusa-react"

    function StockLocations() { const { stock_locations, isLoading } = useAdminStockLocations()

    return ( <div> {isLoading && <span>Loading...</span>} {stock_locations && !stock_locations.length && ( <span>No Locations</span> )} {stock_locations && stock_locations.length > 0 && ( <ul> {stock_locations.map( (location) => ( <li key={location.id}>{location.name}</li> ) )} </ul> )} </div> ) }

    export default StockLocations

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/stock-locations' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Stock Locations

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminStockLocationsListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*StockLocation) SetRoutes

func (m *StockLocation) SetRoutes(router fiber.Router)

func (*StockLocation) Update

func (m *StockLocation) Update(context fiber.Ctx) error

@oas:path [post] /admin/stock-locations/{id} operationId: "PostStockLocationsStockLocation" summary: "Update a Stock Location" description: "Update a Stock Location's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Stock Location.
  • (query) expand {string} Comma-separated relations that should be expanded in the returned stock location.
  • (query) fields {string} Comma-separated fields that should be included in the returned stock location.

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostStockLocationsLocationReq"

x-codegen:

method: update

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.stockLocations.update(stockLocationId, { name: 'Main Warehouse' }) .then(({ stock_location }) => { console.log(stock_location.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateStockLocation } from "medusa-react"

    type Props = { stockLocationId: string }

    const StockLocation = ({ stockLocationId }: Props) => { const updateLocation = useAdminUpdateStockLocation( stockLocationId ) // ...

    const handleUpdate = ( name: string ) => { updateLocation.mutate({ name }, { onSuccess: ({ stock_location }) => { console.log(stock_location.name) } }) } }

    export default StockLocation

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/stock-locations/{id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "name": "Main Warehouse" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Stock Locations

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminStockLocationsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type Store

type Store struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore(r Registry) *Store

func (*Store) AddCurrency

func (m *Store) AddCurrency(context fiber.Ctx) error

@oas:path [post] /admin/store/currencies/{code} operationId: "PostStoreCurrenciesCode" summary: "Add a Currency Code" description: "Add a Currency Code to the available currencies in a store. This does not create new currencies, as currencies are defined within the Medusa backend. To create a currency, you can create a migration that inserts the currency into the database." x-authenticated: true parameters:

x-codegen:

method: addCurrency

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.store.addCurrency("eur") .then(({ store }) => { console.log(store.currencies); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminAddStoreCurrency } from "medusa-react"

    const Store = () => { const addCurrency = useAdminAddStoreCurrency() // ...

    const handleAdd = (code: string) => { addCurrency.mutate(code, { onSuccess: ({ store }) => { console.log(store.currencies) } }) }

    // ... }

    export default Store

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/store/currencies/{currency_code}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Store

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminStoresRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Store) Get

func (m *Store) Get(context fiber.Ctx) error

@oas:path [get] /admin/store operationId: "GetStore" summary: "Get Store details" description: "Retrieve the Store's details." x-authenticated: true x-codegen:

method: 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.store.retrieve() .then(({ store }) => { console.log(store.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminStore } from "medusa-react"

    const Store = () => { const { store, isLoading } = useAdminStore()

    return ( <div> {isLoading && <span>Loading...</span>} {store && <span>{store.name}</span>} </div> ) }

    export default Store

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/store' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Store

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminExtendedStoresRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Store) ListPaymentProviders

func (m *Store) ListPaymentProviders(context fiber.Ctx) error

@oas:path [get] /admin/store/payment-providers operationId: "GetStorePaymentProviders" summary: "List Payment Providers" description: "Retrieve a list of available Payment Providers in a store." x-authenticated: true x-codegen:

method: listPaymentProviders

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.store.listPaymentProviders() .then(({ payment_providers }) => { console.log(payment_providers.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminStorePaymentProviders } from "medusa-react"

    const PaymentProviders = () => { const { payment_providers, isLoading } = useAdminStorePaymentProviders()

    return ( <div> {isLoading && <span>Loading...</span>} {payment_providers && !payment_providers.length && ( <span>No Payment Providers</span> )} {payment_providers && payment_providers.length > 0 &&( <ul> {payment_providers.map((provider) => ( <li key={provider.id}>{provider.id}</li> ))} </ul> )} </div> ) }

    export default PaymentProviders

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/store/payment-providers' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Store

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminPaymentProvidersList"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Store) ListTaxProviders

func (m *Store) ListTaxProviders(context fiber.Ctx) error

@oas:path [get] /admin/store/tax-providers operationId: "GetStoreTaxProviders" summary: "List Tax Providers" description: "Retrieve a list of available Tax Providers in a store." x-authenticated: true x-codegen:

method: listTaxProviders

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.store.listTaxProviders() .then(({ tax_providers }) => { console.log(tax_providers.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminStoreTaxProviders } from "medusa-react"

    const TaxProviders = () => { const { tax_providers, isLoading } = useAdminStoreTaxProviders()

    return ( <div> {isLoading && <span>Loading...</span>} {tax_providers && !tax_providers.length && ( <span>No Tax Providers</span> )} {tax_providers && tax_providers.length > 0 &&( <ul> {tax_providers.map((provider) => ( <li key={provider.id}>{provider.id}</li> ))} </ul> )} </div> ) }

    export default TaxProviders

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/store/tax-providers' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Store

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminTaxProvidersList"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Store) RemoveCurrency

func (m *Store) RemoveCurrency(context fiber.Ctx) error

@oas:path [delete] /admin/store/currencies/{code} operationId: "DeleteStoreCurrenciesCode" summary: "Remove a Currency" description: "Remove a Currency Code from the available currencies in a store. This does not completely delete the currency and it can be added again later to the store." x-authenticated: true parameters:

x-codegen:

method: deleteCurrency

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.store.deleteCurrency("eur") .then(({ store }) => { console.log(store.currencies); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteStoreCurrency } from "medusa-react"

    const Store = () => { const deleteCurrency = useAdminDeleteStoreCurrency() // ...

    const handleAdd = (code: string) => { deleteCurrency.mutate(code, { onSuccess: ({ store }) => { console.log(store.currencies) } }) }

    // ... }

    export default Store

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/store/currencies/{currency_code}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Store

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminStoresRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Store) SetRoutes

func (m *Store) SetRoutes(router fiber.Router)

func (*Store) Update

func (m *Store) Update(context fiber.Ctx) error

@oas:path [post] /admin/store operationId: "PostStore" summary: "Update Store Details" description: "Update the Store's details." x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostStoreReq"

x-codegen:

method: update

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.store.update({ name: "Medusa Store" }) .then(({ store }) => { console.log(store.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateStore } from "medusa-react"

    function Store() { const updateStore = useAdminUpdateStore() // ...

    const handleUpdate = ( name: string ) => { updateStore.mutate({ name }, { onSuccess: ({ store }) => { console.log(store.name) } }) } }

    export default Store

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/store' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "name": "Medusa Store" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Store

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminStoresRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type Swap

type Swap struct {
	// contains filtered or unexported fields
}

func NewSwap

func NewSwap(r Registry) *Swap

func (*Swap) Get

func (m *Swap) Get(context fiber.Ctx) error

@oas:path [get] /admin/swaps/{id} operationId: "GetSwapsSwap" summary: "Get a Swap" description: "Retrieve a Swap's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Swap.

x-codegen:

method: 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.swaps.retrieve(swapId) .then(({ swap }) => { console.log(swap.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminSwap } from "medusa-react"

    type Props = { swapId: string }

    const Swap = ({ swapId }: Props) => { const { swap, isLoading } = useAdminSwap(swapId)

    return ( <div> {isLoading && <span>Loading...</span>} {swap && <span>{swap.id}</span>} </div> ) }

    export default Swap

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/swaps/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Swaps

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminSwapsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Swap) List

func (m *Swap) List(context fiber.Ctx) error

@oas:path [get] /admin/swaps operationId: "GetSwaps" summary: "List Swaps" description: "Retrieve a list of Swaps. The swaps can be paginated." parameters:

  • (query) limit=50 {number} Limit the number of swaps returned.
  • (query) offset=0 {number} The number of swaps to skip when retrieving the swaps.

x-authenticated: true x-codegen:

method: list
queryParams: AdminGetSwapsParams

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.swaps.list() .then(({ swaps }) => { console.log(swaps.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminSwaps } from "medusa-react"

    const Swaps = () => { const { swaps, isLoading } = useAdminSwaps()

    return ( <div> {isLoading && <span>Loading...</span>} {swaps && !swaps.length && <span>No Swaps</span>} {swaps && swaps.length > 0 && ( <ul> {swaps.map((swap) => ( <li key={swap.id}>{swap.payment_status}</li> ))} </ul> )} </div> ) }

    export default Swaps

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/swaps' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Swaps

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminSwapsListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Swap) SetRoutes

func (m *Swap) SetRoutes(router fiber.Router)

type TaxRate

type TaxRate struct {
	// contains filtered or unexported fields
}

func NewTaxRate

func NewTaxRate(r Registry) *TaxRate

func (*TaxRate) AddProductTypes

func (m *TaxRate) AddProductTypes(context fiber.Ctx) error

@oas:path [post] /admin/tax-rates/{id}/product-types/batch operationId: "PostTaxRatesTaxRateProductTypes" summary: "Add to Product Types" description: "Add Product Types to a Tax Rate." parameters:

  • (path) id=* {string} ID of the tax rate.
  • in: query name: fields description: "Comma-separated fields that should be included in the returned tax rate." style: form explode: false schema: type: array items: type: string
  • in: query name: expand description: "Comma-separated relations that should be expanded in the returned tax rate." style: form explode: false schema: type: array items: type: string

x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostTaxRatesTaxRateProductTypesReq"

x-codegen:

method: addProductTypes
queryParams: AdminPostTaxRatesTaxRateProductTypesParams

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.taxRates.addProductTypes(taxRateId, { product_types: [ productTypeId ] }) .then(({ tax_rate }) => { console.log(tax_rate.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateProductTypeTaxRates, } from "medusa-react"

    type Props = { taxRateId: string }

    const TaxRate = ({ taxRateId }: Props) => { const addProductTypes = useAdminCreateProductTypeTaxRates( taxRateId ) // ...

    const handleAddProductTypes = (productTypeIds: string[]) => { addProductTypes.mutate({ product_types: productTypeIds, }, { onSuccess: ({ tax_rate }) => { console.log(tax_rate.product_types) } }) }

    // ... }

    export default TaxRate

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/tax-rates/{id}/product-types/batch' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "product_types": [ {product_type_id}" ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Tax Rates

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminTaxRatesRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*TaxRate) AddToProducts

func (m *TaxRate) AddToProducts(context fiber.Ctx) error

@oas:path [post] /admin/tax-rates/{id}/products/batch operationId: "PostTaxRatesTaxRateProducts" summary: "Add to Products" description: "Add products to a tax rate." parameters:

  • (path) id=* {string} ID of the tax rate.
  • in: query name: fields description: "Comma-separated fields that should be included in the returned tax rate." style: form explode: false schema: type: array items: type: string
  • in: query name: expand description: "Comma-separated relations that should be expanded in the returned tax rate." style: form explode: false schema: type: array items: type: string

x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostTaxRatesTaxRateProductsReq"

x-codegen:

method: addProducts
queryParams: AdminPostTaxRatesTaxRateProductsParams

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.taxRates.addProducts(taxRateId, { products: [ productId ] }) .then(({ tax_rate }) => { console.log(tax_rate.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateProductTaxRates } from "medusa-react"

    type Props = { taxRateId: string }

    const TaxRate = ({ taxRateId }: Props) => { const addProduct = useAdminCreateProductTaxRates(taxRateId) // ...

    const handleAddProduct = (productIds: string[]) => { addProduct.mutate({ products: productIds, }, { onSuccess: ({ tax_rate }) => { console.log(tax_rate.products) } }) }

    // ... }

    export default TaxRate

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/tax-rates/{id}/products/batch' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "products": [ {product_id}" ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Tax Rates

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminTaxRatesRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*TaxRate) AddToShippingOptions

func (m *TaxRate) AddToShippingOptions(context fiber.Ctx) error

@oas:path [post] /admin/tax-rates/{id}/shipping-options/batch operationId: "PostTaxRatesTaxRateShippingOptions" summary: "Add to Shipping Options" description: "Add Shipping Options to a Tax Rate." parameters:

  • (path) id=* {string} ID of the tax rate.
  • in: query name: fields description: "Comma-separated fields that should be included in the returned tax rate." style: form explode: false schema: type: array items: type: string
  • in: query name: expand description: "Comma-separated relations that should be expanded in the returned tax rate." style: form explode: false schema: type: array items: type: string

x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostTaxRatesTaxRateShippingOptionsReq"

x-codegen:

method: addShippingOptions
queryParams: AdminPostTaxRatesTaxRateShippingOptionsParams

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.taxRates.addShippingOptions(taxRateId, { shipping_options: [ shippingOptionId ] }) .then(({ tax_rate }) => { console.log(tax_rate.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateShippingTaxRates } from "medusa-react"

    type Props = { taxRateId: string }

    const TaxRate = ({ taxRateId }: Props) => { const addShippingOption = useAdminCreateShippingTaxRates( taxRateId ) // ...

    const handleAddShippingOptions = ( shippingOptionIds: string[] ) => { addShippingOption.mutate({ shipping_options: shippingOptionIds, }, { onSuccess: ({ tax_rate }) => { console.log(tax_rate.shipping_options) } }) }

    // ... }

    export default TaxRate

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/tax-rates/{id}/shipping-options/batch' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "shipping_options": [ {shipping_option_id}" ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Tax Rates

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminTaxRatesRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*TaxRate) Create

func (m *TaxRate) Create(context fiber.Ctx) error

@oas:path [post] /admin/tax-rates operationId: "PostTaxRates" summary: "Create a Tax Rate" description: "Create a Tax Rate." parameters:

  • in: query name: fields description: "Comma-separated fields that should be included in the returned tax rate." style: form explode: false schema: type: array items: type: string
  • in: query name: expand description: "Comma-separated relations that should be expanded in the returned tax rate." style: form explode: false schema: type: array items: type: string

x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostTaxRatesReq"

x-codegen:

method: create
queryParams: AdminPostTaxRatesParams

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.taxRates.create({ code: "TEST", name: "New Tax Rate", region_id }) .then(({ tax_rate }) => { console.log(tax_rate.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateTaxRate } from "medusa-react"

    type Props = { regionId: string }

    const CreateTaxRate = ({ regionId }: Props) => { const createTaxRate = useAdminCreateTaxRate() // ...

    const handleCreate = ( code: string, name: string, rate: number ) => { createTaxRate.mutate({ code, name, region_id: regionId, rate, }, { onSuccess: ({ tax_rate }) => { console.log(tax_rate.id) } }) }

    // ... }

    export default CreateTaxRate

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/tax-rates' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "code": "TEST", "name": "New Tax Rate", "region_id": "{region_id}" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Tax Rates

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminTaxRatesRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*TaxRate) Delete

func (m *TaxRate) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/tax-rates/{id} operationId: "DeleteTaxRatesTaxRate" summary: "Delete a Tax Rate" description: "Delete a Tax Rate. Resources associated with the tax rate, such as products or product types, are not deleted." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the Shipping Option.

x-codegen:

method: 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.taxRates.delete(taxRateId) .then(({ id, object, deleted }) => { console.log(id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteTaxRate } from "medusa-react"

    type Props = { taxRateId: string }

    const TaxRate = ({ taxRateId }: Props) => { const deleteTaxRate = useAdminDeleteTaxRate(taxRateId) // ...

    const handleDelete = () => { deleteTaxRate.mutate(void 0, { onSuccess: ({ id, object, deleted }) => { console.log(id) } }) }

    // ... }

    export default TaxRate

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/tax-rates/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Tax Rates

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminTaxRatesDeleteRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*TaxRate) Get

func (m *TaxRate) Get(context fiber.Ctx) error

@oas:path [get] /admin/tax-rates/{id} operationId: "GetTaxRatesTaxRate" summary: "Get a Tax Rate" description: "Retrieve a Tax Rate's details." parameters:

  • (path) id=* {string} ID of the tax rate.
  • in: query name: fields description: "Comma-separated fields that should be included in the returned tax rate." style: form explode: false schema: type: array items: type: string
  • in: query name: expand description: "Comma-separated relations that should be expanded in the returned tax rate." style: form explode: false schema: type: array items: type: string

x-authenticated: true x-codegen:

method: retrieve
queryParams: AdminGetTaxRatesTaxRateParams

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.taxRates.retrieve(taxRateId) .then(({ tax_rate }) => { console.log(tax_rate.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminTaxRate } from "medusa-react"

    type Props = { taxRateId: string }

    const TaxRate = ({ taxRateId }: Props) => { const { tax_rate, isLoading } = useAdminTaxRate(taxRateId)

    return ( <div> {isLoading && <span>Loading...</span>} {tax_rate && <span>{tax_rate.code}</span>} </div> ) }

    export default TaxRate

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/tax-rates/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Tax Rates

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminTaxRatesRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*TaxRate) List

func (m *TaxRate) List(context fiber.Ctx) error

@oas:path [get] /admin/tax-rates operationId: "GetTaxRates" summary: "List Tax Rates" description: "Retrieve a list of Tax Rates. The tax rates can be filtered by fields such as `name` or `rate`. The tax rates can also be paginated." x-authenticated: true parameters:

  • (query) name {string} Filter by name.
  • in: query name: region_id style: form explode: false description: Filter by Region IDs schema: oneOf:
  • type: string
  • type: array items: type: string
  • (query) code {string} Filter by code.
  • in: query name: rate style: form explode: false description: Filter by Rate schema: oneOf:
  • type: number
  • type: object properties: lt: type: number description: filter by rates less than this number gt: type: number description: filter by rates greater than this number lte: type: number description: filter by rates less than or equal to this number gte: type: number description: filter by rates greater than or equal to this number
  • (query) offset=0 {integer} The number of tax rates to skip when retrieving the tax rates.
  • (query) limit=50 {integer} Limit the number of tax rates returned.
  • in: query name: fields description: "Comma-separated fields that should be included in the returned tax rate." style: form explode: false schema: type: array items: type: string
  • in: query name: expand description: "Comma-separated relations that should be expanded in the returned tax rate." style: form explode: false schema: type: array items: type: string

x-codegen:

method: list
queryParams: AdminGetTaxRatesParams

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.taxRates.list() .then(({ tax_rates, limit, offset, count }) => { console.log(tax_rates.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminTaxRates } from "medusa-react"

    const TaxRates = () => { const { tax_rates, isLoading } = useAdminTaxRates()

    return ( <div> {isLoading && <span>Loading...</span>} {tax_rates && !tax_rates.length && ( <span>No Tax Rates</span> )} {x_rates && tax_rates.length > 0 && ( <ul> {tax_rates.map((tax_rate) => ( <li key={tax_rate.id}>{tax_rate.code}</li> ))} </ul> )} </div> ) }

    export default TaxRates

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/tax-rates' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Tax Rates

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminTaxRatesListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*TaxRate) RemoveFromProductTypes

func (m *TaxRate) RemoveFromProductTypes(context fiber.Ctx) error

@oas:path [delete] /admin/tax-rates/{id}/product-types/batch operationId: "DeleteTaxRatesTaxRateProductTypes" summary: "Remove Product Types from Rate" description: "Remove product types from a tax rate. This only removes the association between the product types and the tax rate. It does not delete the product types." parameters:

  • (path) id=* {string} ID of the tax rate.
  • in: query name: fields description: "Comma-separated fields that should be included in the returned tax rate." style: form explode: false schema: type: array items: type: string
  • in: query name: expand description: "Comma-separated relations that should be expanded in the returned tax rate." style: form explode: false schema: type: array items: type: string

x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminDeleteTaxRatesTaxRateProductTypesReq"

x-codegen:

method: removeProductTypes
queryParams: AdminDeleteTaxRatesTaxRateProductTypesParams

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.taxRates.removeProductTypes(taxRateId, { product_types: [ productTypeId ] }) .then(({ tax_rate }) => { console.log(tax_rate.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteProductTypeTaxRates, } from "medusa-react"

    type Props = { taxRateId: string }

    const TaxRate = ({ taxRateId }: Props) => { const removeProductTypes = useAdminDeleteProductTypeTaxRates( taxRateId ) // ...

    const handleRemoveProductTypes = ( productTypeIds: string[] ) => { removeProductTypes.mutate({ product_types: productTypeIds, }, { onSuccess: ({ tax_rate }) => { console.log(tax_rate.product_types) } }) }

    // ... }

    export default TaxRate

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/tax-rates/{id}/product-types/batch' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "product_types": [ {product_type_id}" ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Tax Rates

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminTaxRatesRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*TaxRate) RemoveFromProducts

func (m *TaxRate) RemoveFromProducts(context fiber.Ctx) error

@oas:path [delete] /admin/tax-rates/{id}/products/batch operationId: "DeleteTaxRatesTaxRateProducts" summary: "Remove Products from Rate" description: "Remove products from a tax rate. This only removes the association between the products and the tax rate. It does not delete the products." parameters:

  • (path) id=* {string} ID of the tax rate.
  • in: query name: fields description: "Comma-separated fields that should be included in the returned tax rate." style: form explode: false schema: type: array items: type: string
  • in: query name: expand description: "Comma-separated relations that should be expanded in the returned tax rate." style: form explode: false schema: type: array items: type: string

x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminDeleteTaxRatesTaxRateProductsReq"

x-codegen:

method: removeProducts
queryParams: AdminDeleteTaxRatesTaxRateProductsParams

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.taxRates.removeProducts(taxRateId, { products: [ productId ] }) .then(({ tax_rate }) => { console.log(tax_rate.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteProductTaxRates } from "medusa-react"

    type Props = { taxRateId: string }

    const TaxRate = ({ taxRateId }: Props) => { const removeProduct = useAdminDeleteProductTaxRates(taxRateId) // ...

    const handleRemoveProduct = (productIds: string[]) => { removeProduct.mutate({ products: productIds, }, { onSuccess: ({ tax_rate }) => { console.log(tax_rate.products) } }) }

    // ... }

    export default TaxRate

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/tax-rates/{id}/products/batch' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "products": [ {product_id}" ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Tax Rates

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminTaxRatesRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*TaxRate) RemoveFromShippingOptions

func (m *TaxRate) RemoveFromShippingOptions(context fiber.Ctx) error

@oas:path [delete] /admin/tax-rates/{id}/shipping-options/batch operationId: "DeleteTaxRatesTaxRateShippingOptions" summary: "Remove Shipping Options from Rate" description: "Remove shipping options from a tax rate. This only removes the association between the shipping options and the tax rate. It does not delete the shipping options." parameters:

  • (path) id=* {string} ID of the tax rate.
  • in: query name: fields description: "Comma-separated fields that should be included in the returned tax rate." style: form explode: false schema: type: array items: type: string
  • in: query name: expand description: "Comma-separated relations that should be expanded in the returned tax rate." style: form explode: false schema: type: array items: type: string

x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminDeleteTaxRatesTaxRateShippingOptionsReq"

x-codegen:

method: removeShippingOptions
queryParams: AdminDeleteTaxRatesTaxRateShippingOptionsParams

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.taxRates.removeShippingOptions(taxRateId, { shipping_options: [ shippingOptionId ] }) .then(({ tax_rate }) => { console.log(tax_rate.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteShippingTaxRates } from "medusa-react"

    type Props = { taxRateId: string }

    const TaxRate = ({ taxRateId }: Props) => { const removeShippingOptions = useAdminDeleteShippingTaxRates( taxRateId ) // ...

    const handleRemoveShippingOptions = ( shippingOptionIds: string[] ) => { removeShippingOptions.mutate({ shipping_options: shippingOptionIds, }, { onSuccess: ({ tax_rate }) => { console.log(tax_rate.shipping_options) } }) }

    // ... }

    export default TaxRate

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/tax-rates/{id}/shipping-options/batch' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "shipping_options": [ {shipping_option_id}" ] }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Tax Rates

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminTaxRatesRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*TaxRate) SetRoutes

func (m *TaxRate) SetRoutes(router fiber.Router)

func (*TaxRate) Update

func (m *TaxRate) Update(context fiber.Ctx) error

@oas:path [post] /admin/tax-rates/{id} operationId: "PostTaxRatesTaxRate" summary: "Update a Tax Rate" description: "Update a Tax Rate's details." parameters:

  • (path) id=* {string} ID of the tax rate.
  • in: query name: fields description: "Comma-separated fields that should be included in the returned tax rate." style: form explode: false schema: type: array items: type: string
  • in: query name: expand description: "Comma-separated relations that should be expanded in the returned tax rate." style: form explode: false schema: type: array items: type: string

x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostTaxRatesTaxRateReq"

x-codegen:

method: update
queryParams: AdminPostTaxRatesTaxRateParams

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.taxRates.update(taxRateId, { name: "New Tax Rate" }) .then(({ tax_rate }) => { console.log(tax_rate.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateTaxRate } from "medusa-react"

    type Props = { taxRateId: string }

    const TaxRate = ({ taxRateId }: Props) => { const updateTaxRate = useAdminUpdateTaxRate(taxRateId) // ...

    const handleUpdate = ( name: string ) => { updateTaxRate.mutate({ name }, { onSuccess: ({ tax_rate }) => { console.log(tax_rate.name) } }) }

    // ... }

    export default TaxRate

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/tax-rates/{id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "name": "New Tax Rate" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Tax Rates

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminTaxRatesRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type Upload

type Upload struct {
	// contains filtered or unexported fields
}

func NewUpload

func NewUpload(r Registry) *Upload

func (*Upload) Create

func (m *Upload) Create(context fiber.Ctx) error

@oas:path [post] /admin/uploads operationId: "PostUploads" summary: "Upload Files" description: "Upload at least one file to a public bucket or storage. The file upload is handled by the file service installed on the Medusa backend." x-authenticated: true requestBody:

content:
  multipart/form-data:
    schema:
      type: object
      properties:
        files:
          type: string
          format: binary

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.uploads.create(file) .then(({ uploads }) => { console.log(uploads.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUploadFile } from "medusa-react"

    const UploadFile = () => { const uploadFile = useAdminUploadFile() // ...

    const handleFileUpload = (file: File) => { uploadFile.mutate(file, { onSuccess: ({ uploads }) => { console.log(uploads[0].key) } }) }

    // ... }

    export default UploadFile

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/uploads' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: image/jpeg' \ --form 'files=@"<FILE_PATH_1>"' \ --form 'files=@"<FILE_PATH_1>"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Uploads

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminUploadsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Upload) CreateProtectedUpload

func (m *Upload) CreateProtectedUpload(context fiber.Ctx) error

@oas:path [post] /admin/uploads/protected operationId: "PostUploadsProtected" summary: "Protected File Upload" description: "Upload at least one file to an ACL or a non-public bucket. The file upload is handled by the file service installed on the Medusa backend." x-authenticated: true requestBody:

content:
  multipart/form-data:
    schema:
      type: object
      properties:
        files:
          type: string
          format: binary

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.uploads.createProtected(file) .then(({ uploads }) => { console.log(uploads.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUploadProtectedFile } from "medusa-react"

    const UploadFile = () => { const uploadFile = useAdminUploadProtectedFile() // ...

    const handleFileUpload = (file: File) => { uploadFile.mutate(file, { onSuccess: ({ uploads }) => { console.log(uploads[0].key) } }) }

    // ... }

    export default UploadFile

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/uploads/protected' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: image/jpeg' \ --form 'files=@"<FILE_PATH_1>"' \ --form 'files=@"<FILE_PATH_1>"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Uploads

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminUploadsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Upload) Delete

func (m *Upload) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/uploads operationId: "DeleteUploads" summary: "Delete an Uploaded File" description: "Delete an uploaded file from storage. The file is deleted using the installed file service on the Medusa backend." x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminDeleteUploadsReq"

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.uploads.delete({ file_key }) .then(({ id, object, deleted }) => { console.log(id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteFile } from "medusa-react"

    const Image = () => { const deleteFile = useAdminDeleteFile() // ...

    const handleDeleteFile = (fileKey: string) => { deleteFile.mutate({ file_key: fileKey }, { onSuccess: ({ id, object, deleted }) => { console.log(id) } }) }

    // ... }

    export default Image

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/uploads' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "file_key": "{file_key}" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Uploads

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDeleteUploadsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Upload) Get

func (m *Upload) Get(context fiber.Ctx) error

@oas:path [post] /admin/uploads/download-url operationId: "PostUploadsDownloadUrl" summary: "Get a File's Download URL" description: "Create and retrieve a presigned or public download URL for a file. The URL creation is handled by the file service installed on the Medusa backend." x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminPostUploadsDownloadUrlReq"

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.uploads.getPresignedDownloadUrl({ file_key }) .then(({ download_url }) => { console.log(download_url); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreatePresignedDownloadUrl } from "medusa-react"

    const Image = () => { const createPresignedUrl = useAdminCreatePresignedDownloadUrl() // ...

    const handlePresignedUrl = (fileKey: string) => { createPresignedUrl.mutate({ file_key: fileKey }, { onSuccess: ({ download_url }) => { console.log(download_url) } }) }

    // ... }

    export default Image

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/uploads/download-url' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "file_key": "{file_key}" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Uploads

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminUploadsDownloadUrlRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Upload) SetRoutes

func (m *Upload) SetRoutes(router fiber.Router)

type User

type User struct {
	// contains filtered or unexported fields
}

func NewUser

func NewUser(r Registry) *User

func (*User) Create

func (m *User) Create(context fiber.Ctx) error

@oas:path [post] /admin/users operationId: "PostUsers" summary: "Create a User" description: "Create an admin User. The user has the same privileges as all admin users, and will be able to authenticate and perform admin functionalities right after creation." x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminCreateUserRequest"

x-codegen:

method: 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.users.create({ email: "[email protected]", password: "supersecret" }) .then(({ user }) => { console.log(user.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminCreateUser } from "medusa-react"

    const CreateUser = () => { const createUser = useAdminCreateUser() // ...

    const handleCreateUser = () => { createUser.mutate({ email: "[email protected]", password: "supersecret", }, { onSuccess: ({ user }) => { console.log(user.id) } }) }

    // ... }

    export default CreateUser

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/users' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "email": "[email protected]", "password": "supersecret" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Users

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminUserRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*User) Delete

func (m *User) Delete(context fiber.Ctx) error

@oas:path [delete] /admin/users/{id} operationId: "DeleteUsersUser" summary: "Delete a User" description: "Delete a User. Once deleted, the user will not be able to authenticate or perform admin functionalities." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the User.

x-codegen:

method: 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.users.delete(userId) .then(({ id, object, deleted }) => { console.log(id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminDeleteUser } from "medusa-react"

    type Props = { userId: string }

    const User = ({ userId }: Props) => { const deleteUser = useAdminDeleteUser(userId) // ...

    const handleDeleteUser = () => { deleteUser.mutate(void 0, { onSuccess: ({ id, object, deleted }) => { console.log(id) } }) }

    // ... }

    export default User

  • lang: Shell label: cURL source: | curl -X DELETE '"{backend_url}"/admin/users/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Users

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminDeleteUserRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*User) Get

func (m *User) Get(context fiber.Ctx) error

@oas:path [get] /admin/users/{id} operationId: "GetUsersUser" summary: "Get a User" description: "Retrieve an admin user's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the User.

x-codegen:

method: 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.users.retrieve(userId) .then(({ user }) => { console.log(user.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUser } from "medusa-react"

    type Props = { userId: string }

    const User = ({ userId }: Props) => { const { user, isLoading } = useAdminUser( userId )

    return ( <div> {isLoading && <span>Loading...</span>} {user && <span>{user.first_name} {user.last_name}</span>} </div> ) }

    export default User

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/users/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Users

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminUserRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*User) List

func (m *User) List(context fiber.Ctx) error

@oas:path [get] /admin/users operationId: "GetUsers" summary: "List Users" description: "Retrieves a list of users. The users can be filtered by fields such as `q` or `email`. The users can also be sorted or paginated." x-authenticated: true parameters:

  • (query) email {string} Filter by email.
  • (query) first_name {string} Filter by first name.
  • (query) last_name {string} Filter by last name.
  • (query) q {string} Term used to search users' first name, last name, and email.
  • (query) order {string} A user field to sort-order the retrieved users by.
  • in: query name: id style: form explode: false description: Filter by user IDs. schema: oneOf:
  • type: string description: ID of the user.
  • type: array items: type: string description: ID of a user.
  • in: query name: created_at description: Filter by a creation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: updated_at description: Filter by an update date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • in: query name: deleted_at description: Filter by a deletion date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
  • (query) offset=0 {integer} The number of users to skip when retrieving the users.
  • (query) limit=20 {integer} Limit the number of users returned.
  • (query) fields {string} Comma-separated fields that should be included in the returned users.

x-codegen:

method: list
queryParams: AdminGetUsersParams

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.users.list() .then(({ users, limit, offset, count }) => { console.log(users.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUsers } from "medusa-react"

    const Users = () => { const { users, isLoading } = useAdminUsers()

    return ( <div> {isLoading && <span>Loading...</span>} {users && !users.length && <span>No Users</span>} {users && users.length > 0 && ( <ul> {users.map((user) => ( <li key={user.id}>{user.email}</li> ))} </ul> )} </div> ) }

    export default Users

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/users' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Users

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminUsersListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*User) ResetPassword

func (m *User) ResetPassword(context fiber.Ctx) error

@oas:path [post] /admin/users/reset-password operationId: "PostUsersUserPassword" summary: "Reset Password" description: "Reset the password of an admin User using their reset password token. A user must request to reset their password first before attempting to reset their password with this request." externalDocs:

description: How to reset a user's password
url: https://docs.medusajs.com/modules/users/admin/manage-profile#reset-password

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminResetPasswordRequest"

x-codegen:

method: resetPassword

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.users.resetPassword({ token: "supersecrettoken", password: "supersecret" }) .then(({ user }) => { console.log(user.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminResetPassword } from "medusa-react"

    const ResetPassword = () => { const resetPassword = useAdminResetPassword() // ...

    const handleResetPassword = ( token: string, password: string ) => { resetPassword.mutate({ token, password, }, { onSuccess: ({ user }) => { console.log(user.id) } }) }

    // ... }

    export default ResetPassword

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/users/reset-password' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "token": "supersecrettoken", "password": "supersecret" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Users

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminUserRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*User) ResetPasswordTocken

func (m *User) ResetPasswordTocken(context fiber.Ctx) error

@oas:path [post] /admin/users/password-token operationId: "PostUsersUserPasswordToken" summary: "Request Password Reset" description: "Generate a password token for an admin user with a given email. This also triggers the `user.password_reset` event. So, if you have a Notification Service installed that can handle this event, a notification, such as an email, will be sent to the user. The token is triggered as part of the `user.password_reset` event's payload. That token must be used later to reset the password using the [Reset Password](https://docs.medusajs.com/api/admin#users_postusersuserpassword) API Route." externalDocs:

description: How to reset a user's password
url: https://docs.medusajs.com/modules/users/admin/manage-profile#reset-password

requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminResetPasswordTokenRequest"

x-codegen:

method: sendResetPasswordToken

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.users.sendResetPasswordToken({ email: "[email protected]" }) .then(() => { // successful }) .catch(() => { // error occurred })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminSendResetPasswordToken } from "medusa-react"

    const Login = () => { const requestPasswordReset = useAdminSendResetPasswordToken() // ...

    const handleResetPassword = ( email: string ) => { requestPasswordReset.mutate({ email }, { onSuccess: () => { // successful } }) }

    // ... }

    export default Login

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/users/password-token' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "email": "[email protected]" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Users

responses:

204:
  description: "OK"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*User) SetRoutes

func (m *User) SetRoutes(router fiber.Router)

func (*User) UnauthenticatedUserRoutes

func (m *User) UnauthenticatedUserRoutes(router fiber.Router)

func (*User) Update

func (m *User) Update(context fiber.Ctx) error

@oas:path [post] /admin/users/{id} operationId: "PostUsersUser" summary: "Update a User" description: "Update an admin user's details." parameters:

  • (path) id=* {string} The ID of the User.

x-authenticated: true requestBody:

content:
  application/json:
    schema:
      $ref: "#/components/schemas/AdminUpdateUserRequest"

x-codegen:

method: update

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.users.update(userId, { first_name: "Marcellus" }) .then(({ user }) => { console.log(user.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminUpdateUser } from "medusa-react"

    type Props = { userId: string }

    const User = ({ userId }: Props) => { const updateUser = useAdminUpdateUser(userId) // ...

    const handleUpdateUser = ( firstName: string ) => { updateUser.mutate({ first_name: firstName, }, { onSuccess: ({ user }) => { console.log(user.first_name) } }) }

    // ... }

    export default User

  • lang: Shell label: cURL source: | curl -X POST '"{backend_url}"/admin/users/{id}' \ -H 'x-medusa-access-token: "{api_token}"' \ -H 'Content-Type: application/json' \ --data-raw '{ "first_name": "Marcellus" }'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Users

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminUserRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

type Variant

type Variant struct {
	// contains filtered or unexported fields
}

func NewVariant

func NewVariant(r Registry) *Variant

func (*Variant) Get

func (m *Variant) Get(context fiber.Ctx) error

@oas:path [get] /admin/variants/{id} operationId: "GetVariantsVariant" summary: "Get a Product variant" description: "Retrieve a product variant's details." x-authenticated: true parameters:

  • (path) id=* {string} The ID of the product variant.
  • (query) expand {string} "Comma-separated relations that should be expanded in the returned product variant."
  • (query) fields {string} "Comma-separated fields that should be included in the returned product variant."

x-codegen:

method: retrieve
queryParams: AdminGetVariantParams

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.variants.retrieve(variantId) .then(({ variant }) => { console.log(variant.id); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminVariant } from "medusa-react"

    type Props = { variantId: string }

    const Variant = ({ variantId }: Props) => { const { variant, isLoading } = useAdminVariant( variantId )

    return ( <div> {isLoading && <span>Loading...</span>} {variant && <span>{variant.title}</span>} </div> ) }

    export default Variant

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/variants/{id}' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Product Variants

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminVariantsRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Variant) GetInventory

func (m *Variant) GetInventory(context fiber.Ctx) error

@oas:path [get] /admin/variants/{id}/inventory operationId: "GetVariantsVariantInventory" summary: "Get Variant's Inventory" description: "Retrieve the available inventory of a Product Variant." x-authenticated: true parameters:

  • (path) id {string} The Product Variant ID.

x-codegen:

method: getInventory

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.variants.getInventory(variantId) .then(({ variant }) => { console.log(variant.inventory, variant.sales_channel_availability) })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminVariantsInventory } from "medusa-react"

    type Props = { variantId: string }

    const VariantInventory = ({ variantId }: Props) => { const { variant, isLoading } = useAdminVariantsInventory( variantId )

    return ( <div> {isLoading && <span>Loading...</span>} {variant && variant.inventory.length === 0 && ( <span>Variant doesn't have inventory details</span> )} {variant && variant.inventory.length > 0 && ( <ul> {variant.inventory.map((inventory) => ( <li key={inventory.id}>{inventory.title}</li> ))} </ul> )} </div> ) }

    export default VariantInventory

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/variants/{id}/inventory' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Product Variants

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminGetVariantsVariantInventoryRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Variant) List

func (m *Variant) List(context fiber.Ctx) error

@oas:path [get] /admin/variants operationId: "GetVariants" summary: "List Product Variants" description: "Retrieve a list of Product Variants. The product variant can be filtered by fields such as `id` or `title`. The product variant can also be paginated." x-authenticated: true parameters:

  • in: query name: id style: form explode: false description: Filter by product variant IDs. schema: oneOf:
  • type: string description: A product variant ID.
  • type: array description: An array of product variant IDs. items: type: string
  • (query) expand {string} "Comma-separated relations that should be expanded in the returned product variants."
  • (query) fields {string} "Comma-separated fields that should be included in the returned product variants."
  • (query) offset=0 {number} The number of product variants to skip when retrieving the product variants.
  • (query) limit=100 {number} Limit the number of product variants returned.
  • in: query name: cart_id style: form explode: false description: The ID of the cart to use for the price selection context. schema: type: string
  • in: query name: region_id style: form explode: false description: The ID of the region to use for the price selection context. schema: type: string externalDocs: description: "Price selection context overview" url: "https://docs.medusajs.com/modules/price-lists/price-selection-strategy#context-object"
  • in: query name: currency_code style: form explode: false description: The 3 character ISO currency code to use for the price selection context. schema: type: string externalDocs: description: "Price selection context overview" url: "https://docs.medusajs.com/modules/price-lists/price-selection-strategy#context-object"
  • in: query name: customer_id style: form explode: false description: The ID of the customer to use for the price selection context. schema: type: string externalDocs: description: "Price selection context overview" url: "https://docs.medusajs.com/modules/price-lists/price-selection-strategy#context-object"
  • in: query name: title style: form explode: false description: Filter by title. schema: oneOf:
  • type: string description: a single title to filter by
  • type: array description: multiple titles to filter by items: type: string
  • in: query name: inventory_quantity description: Filter by available inventory quantity schema: oneOf:
  • type: number description: a specific number to filter by.
  • type: object description: filter using less and greater than comparisons. properties: lt: type: number description: filter by inventory quantity less than this number gt: type: number description: filter by inventory quantity greater than this number lte: type: number description: filter by inventory quantity less than or equal to this number gte: type: number description: filter by inventory quantity greater than or equal to this number

x-codegen:

method: list
queryParams: AdminGetVariantsParams

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.variants.list() .then(({ variants, limit, offset, count }) => { console.log(variants.length); })

  • lang: tsx label: Medusa React source: | import React from "react" import { useAdminVariants } from "medusa-react"

    const Variants = () => { const { variants, isLoading } = useAdminVariants()

    return ( <div> {isLoading && <span>Loading...</span>} {variants && !variants.length && ( <span>No Variants</span> )} {variants && variants.length > 0 && ( <ul> {variants.map((variant) => ( <li key={variant.id}>{variant.title}</li> ))} </ul> )} </div> ) }

    export default Variants

  • lang: Shell label: cURL source: | curl '"{backend_url}"/admin/variants' \ -H 'x-medusa-access-token: "{api_token}"'

security:

  • api_token: []
  • cookie_auth: []
  • jwt_token: []

tags:

  • Product Variants

responses:

200:
  description: "OK"
  content:
    application/json:
      schema:
        $ref: "#/components/schemas/AdminVariantsListRes"
"400":
  description: "Bad Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/400_error"
"401":
  description: "Unauthorized"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/unauthorized"
"404":
  description: "Not Found"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/not_found_error"
"409":
  description: "Invalid State"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_state_error"
"422":
  description: "Invalid Request"
  content:
    application/json:
      schema:
        $ref:  "#/components/responses/invalid_request_error"
"500":
  description: "Internal Server"
  content:
    application/json:
      schema:
        $ref: "#/components/responses/500_error"

func (*Variant) SetRoutes

func (m *Variant) SetRoutes(router fiber.Router)

type VariantInventory

type VariantInventory struct {
	Id                       uuid.UUID                  `json:"id"`
	Inventory                []ResponseInventoryItem    `json:"inventory"`
	SalesChannelAvailability []SalesChannelAvailability `json:"sales_channel_availability"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL