Programatic way to create a note for a company using REST?
Hi Twenty team π
Loving the extensibility of twenty! I've had great luck using the api to tidy up my CRM, see for example https://discord.com/channels/1130383047699738754/1244820584723120242/1244899581829845082
I am now trying to create a note via the rest api for a company, but I can't wrap my head around the playground docs.
Assuming I have already obtained the company id that i need, e.g.
company_id = 1983887e-1c8d-4cc2-a0b4-a747890d182d
Do I use https://docs.twenty.com/rest-api/core#/operations/createOneActivity to make a note? Is there a minimal example somewhere of how to create a note via the api?
Thanks again!Welcome | Twenty - Documentation
Twenty is a CRM designed to fit your unique business needs.
15 Replies
Hi @Rob!
There is a morph many to many relation between objects and activities. It is materialized throught the activityTarget table that has the following columns to represent the morph many to many relation:
- activityId
- companyId
- personId
- opportunityId
- myCustomObject1Id
- ...
So to create a note through the API, you'll need to create an activity, and then create an activityTarget with your activityId and companyId
Thanks Charles. I am just trying to do this now. As step 1, I am trying to create the activity. Using the web ui the following input fails (code as shown in the api web ui
with the error
Do you have any suggestions what i am doing wrong? I can't see where the value "first" is being created
![No description](https://cdn.answeroverflow.com/1253608334498467900/image.png)
@martmull could you take a look, it seems that the REST Api is trying to send a position field to the underlying GraphQL API (it does not exist on Activity as it's not a first class citizen object)
ok
ty!
Thanks!
Yes! @Rob Thanks for pointing this out. Trying to create the activity and getting a 400 error was driving me notes XD
I'm going to take a look at this issue today as it seems high priority
fix is coming -> https://github.com/twentyhq/twenty/pull/6010
GitHub
Remove useless api position parameter by martmull Β· Pull Request #6...
remove buggy addition of position parameter
check created records are in first position by default
deployed on prod @Rob @danemyers
Amazing. Thank you
@martmull do we need to run any migrations or any commands to use the new v0.20.2 release to test this? I am getting some errors (see https://discord.com/channels/1130383047699738754/1255117133386354742)
I believe this is fixed!
@charles I justed tested this, and it is fixed!! Thanks twenty team
great!