Auto-fill created_by field

I hear you, have had to do the same in my project. Seems if you want to update data via the API it’s necessary to duplicate a lot of the good functionality that the admin panel already includes. It’s not gonna stress the DB much, just untidy.

I tag the logged in users ID against the object via some custom controller logic which you might find helpful…

// src/api/[apiname]/controllers/apiname.js
module.exports = createCoreController("api::retreat.retreat", ({ strapi }) => ({
  async create(ctx) {
    // assign the current user as the owner of the retreat
    Object.assign(ctx.request.body.data, { owner: ctx.state.user.id });

    const response = await super.create(ctx);

    return response;
  },
}));

Doesn’t make sense to me that the users are split and I need to re-create all the Author / Editor functionality… we can’t give our users the admin panel as they are very non-technical.