API - How to expand my api route

Hi,

According to the documentation, I created my api with this url: https://directus.royalinmuebles.com/api/v1/accounts

To this, the configuration of /accounts/index.js and package.json are working well.

But know, I need to create the api with this url: https://directus.royalinmuebles.com/api/v1/accounts/1/customers and it’s not possible that works.

Please, can you help me?

Thanks

John

1 Like

Try to do something like this in the index file

import { defineEndpoint } from '@directus/extensions-sdk';

export default defineEndpoint({
  id: 'api/v1',
  handler: (router, { services, env }) => {
    router.post('/accounts/1/customers', async (req, res) => {
      // logic
    });
  }
});