Human readable Order ID's?


Hi there!

Are there any plans to support shorter/human readable Order ID’s?

Right now they’re something like Order #deaddd35-d2d2-4a23-ae32-3c68fb0c45f5, which is pretty long to give to a customer.



Hey :wave:

This has came up a few times and I’ll share again with our product and engineering team, we’d love to do this but it’s currently not a feature.

You could attempt to do this yourself with custom flows fields and our integrations API. When a product is created you could trigger a function to increment a flow field value based on the previous or generate unique shorter IDs.

I’m happy to put together a quick solution using shorter IDs with our integrations API if this approach is of any interest.

Have a great day :grinning:


Hey Jamie!

Thanks for getting back to me so quickly.

The flows API is something I have yet to wrap my head around so if you could put together a quick example that would be very much appreciated! I’m using the JS SDK if that’s of relevance.

Thanks again!


Hey @HelloTiago

Awesome! We’re still figuring out the best way to deliver content around Flows that explains the true power. Essentially it’s a content API that allows you to define fields and store data as entries. You can also extend core resources like products and categories so you can attach additional data to resources.

I’ll put something together now :smile:


Hi @HelloTiago :tada:

I’ve created a short function that runs on Zeit Now that you can use with our integrations API. Please head over to the GitHub repo to see how to download and install the function.

I’ve outlined the steps below needed to make this work - I’ll update the GitHub README over the next few days to include this for future reference too :smile:

1. Create a new Flow



Extending orders resource with a custom flow


2. Edit the new orders flow

3. Add a new Field to orders


Short ID (managed by integrations event)




This is a short ID managed by an order.created event.

4. Deploy the function to Zeit Now

You could also convert this to be a Serverless function that runs on AWS Lambda, Microsoft Azure, Google Functions etc. Take a note of the endpoint you get back from Zeit Now, you’ll need this in the next step.

5. Create a new integration via the integrations API endpoint

POST to with the following payload:

  "data": {
    "type": "integration",
    "name": "Short order ID",
    "description": "Automatically create a short order ID",
    "enabled": true,
    "observes": [
    "integration_type": "webhook",
    "configuration": {
      "url": “<ZEIT_URL_GOES_HERE>”

Now if you create an order, you should see that the short_id on any order is updated with a shorter random string.

You’ll be able to see this field inside the Dashboard too.


Of course you could replace the cuid package with something that generates a random number, based on the current time, but I’ll leave this level of detail up to you :smile: There is also which is another great library.

I hope this helps :sunny:

PS. You’ll need to the Zeit Now CLI on your machine to deploy this function.

Moltin short order ID webhook
"Unique" flow field attribute behavior

Hi @notrab!

Thanks for putting this together!

I’ve followed all your steps and managed to get a Short ID being generated and showing up in the Dashboard. I’d like to present this short ID on the website to the user too, however I don’t think that’s possible with an implicit token, right?

That’s strange though, as your demo React store has the same method I’m trying to use but am getting a permission error:

I also tried the following but the orderInfo variable is just an empty object :confused:

Moltin.Orders.Payment(, paymentData)
   .then((orderInfo) => {



@HelloTiago If you’re trying to retrieve an order implicitly you’ll have to pass a token as a parameter for the customer associated with the order.

// Authenticate your customer and return a JWT
const { data: { token } } = await Moltin.Customers.Token(email, password)

// Retrieve the order record
const { data: order } = await Moltin.Orders.Get(orderId, token)


@Jonathan Is there no other way to access the short order ID field? We’re not creating customer accounts in our app (it’s a straightforward order page) but we’d still like to show the short ID on the “Thank you” page.


Does the order object returned when you call Moltin.Cart().Checkout() not contain your custom field?


@jonathan It does not, no :confused:


That makes sense, as the webhook to add the short order reference is triggered on the order.created event and at that point you’ve already had the response from the checkout call.

Seemingly the only way to achieve this right now with implicit credentials is via the customer token method (suggested above :point_up: ). Unless @notrab has some other suggestions? :thinking:


Hey @HelloTiago @jonathan :wave:

I think the only way to achieve what you’re asking (show short ID on confirm order screen) is to either update the page after it loads with a call to the order again after X seconds. You could fake the user confirmation screen with some indicator, when all it’s doing is polling to see if short_id is present.

This process would be a lot easier if using Flows you could provide the cart with custom data that is transferred to orders. You can see what’s possible with Flows over here.

Hopefully that gives you some thoughts, I’ll make sure to raise the cart custom data to order flow issue internally, which may unblock you and many others :smile:


I think the only way to achieve what you’re asking (show short ID on confirm order screen) is to either update the page after it loads with a call to the order again after X seconds.

This is what I attempted though and ran into the issue described above: the GET Order endpoint doesn’t work via the JS SDK with Implicit tokens. Is there any chance that could be updated on your end? Make the GET order endpoint accessible with Implicit tokens?

Thanks again!


Hey @HelloTiago

Unfortunately that wouldn’t be something I could see happen. The order resource contains sensitive information that should be locked behind a secret token.

You could however build your own service that exposes the short_id. For example the following function would return the short_id. You could then use this to poll for changes.

const { send } = require('micro')
const { get, router } = require('microrouter')
const cors = require('micro-cors')()
const moltinGateway = require('@moltin/sdk').gateway

const moltin = moltinGateway({
  client_id: process.env.MOLTIN_CLIENT_ID,
  client_secret: process.env.MOLTIN_CLIENT_SECRET

module.exports = cors(
    get('/:orderId', async (req, res) => {
      const { orderId } = req.params

      try {
        const {
          json: {
            data: { short_id }
        } = await moltin.Orders.Get(orderId)

        send(res, 200, {
      } catch ({ status, json }) {
        send(res, status, json)

PS. The above is using a slightly modified SDK we’re testing to be state free. You can see the package.json over on GitHub Gist.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.