Skip to content

Create function

POST/admin/v1/stores/{store_id}/functions
  • functions:manage
  • Idempotency-Key supported

Adds a function, switched on, last in its target's order. The module must compile as a WASI command.

Path parameters

  • store_idstringrequired

    The store's ID, like store_01k8qs5s…. Apps get it with the install, in the OAuth redirect and the token response.

Headers

  • Idempotency-Keystring

    Send the same key to retry safely: the first answer is replayed for 24 hours.

  • shop-api-versionYYYY-MM

    The version to answer in. Without it, your app’s pinned version, else the newest.

Body

  • targetenumrequired

    Where in checkout a function runs.

    • discount
    • delivery
    • payment
    • routing
  • titlestringrequired
  • modulestringrequired

    The compiled wasm32-wasip1 command, base64 (standard alphabet), up to 256 KB.

Returns

201 Added.

Errors

  • 409Ten functions for the target already (too_many_functions).
  • 422validation_failedThe module doesn't compile, or the title is invalid.