Create Contributor (staff users) via API?

Hi everyone,

is there any way to create staff users via API? Currently, I only see an option members.

Yes, I was looking for that a few weeks back and found it through the browser developer tools:

A post request to /ghost/api/admin/invites/ will do the trick and send a staff invitation to the email address in the request.

The payload is an array of invites, like this:

[
  {
    "email": "example@example.com",
    "role_id": "blabla"
  }
]

The role_id is an id that’s set in your database, though you could also get all available roles programmatically (if you’re on a hosted Ghost version without database access) through a GET request to /ghost/api/admin/roles/.

3 Likes

Thanks for the idea @jannis . It is not 100% what I was imagining, but could be a workaround. I was trying to avoid any contact by the contributor with Ghost and just use it as the frontend of a headless user management & content publishing system.

Use case:

  • Guest post provided by the user, written somewhere else.
  • User and article management are completely outside of Ghost (could be in Airtable for example)
  • In this case, Ghost should just be the frontend to publish the article and to bring together content + author(s) inc. author pages.

Since members can’t “have” articles and author pages, the contributor role is the required minimum. So a “create staff user” request in the admin API would solve the issue.

Since the Ghost Admin isn’t really headless, I don’t really see an option to make this work inside Ghost. The /invites endpoint is as far as we get, I think.

If you want zero touchpoints between the contributor and Ghost, I’d rather think of an authentication system outside of Ghost. You’d somehow need to manually (or through the /invites API) get the author profiles into Ghost, but since you don’t want these contributors to interact with the software, a simple dummy email you control could do the trick here.

1 Like

Right, I didn’t think about using my own email (or one that is controlled by me). This way, I could indeed simply “accept” the invite and create the user this way. Thanks again!

1 Like