How to create entries with many-to-one relationship through API?

System Information
  • Strapi Version: v4.0.0
  • Operating System: Mac OS Monterey 12.0.1
  • Database: Postgres 13
  • Node Version: v14.17.1
  • NPM Version: 7.20.0
  • Yarn Version: 1.22.17


I created a collection with many-to-one relationship fields.

    data: {
        customer: {
            id: 1

I tried to include json in the body, but it didn’t work.

I would like to know how to create entries with many-to-one relationship through API?

Thank you.

To relate collection types using a post request, you need to send the body data like:

    data: {
        customer: [id] #this is the id of the customer collection type 
1 Like


I have the same problem with a collection of favorites that has 2 relationships “users” and “games” but this does not do the CREATE: POST, I can’t do a GET of “games” either, it doesn’t show me that relationship what can I do???

You can access those related fields with a get call at http://localhost:1337/api/favorites?populate=%2A

SOLVED: CREATE of the GAME collection type is enabled, that’s why it didn’t work because you have to enable the CREATE of the FIELD of the relation to which the post is made, I already solved it friend, the problem was the CREATE of the type field itself of game collection since I had to enable this same thing I did not know, I thought that the CREATE of my favorite collection already had all the permissions to use users and the game field but it is not like that, it has to be enabled also in roles and permissions, your own CREATE of the GAME collection type