Unable to create new contact in Freshsales/Freshworks CRM API

I am having issues creating a new contact using the CRM API.

I am executing this cURL command:

curl -H "Authorization: Token token=TOKEN" -H "Content-Type: application/json" -X POST "https://XXX.myfreshworks.com/crm/sales/api/contacts" -d '{"contact": {"first_name":Test,"last_name":Test,"display_name":"Test test","avatar":null,"job_title":null,"city":"Tbilisi","state":"K'alak'i T'bilisi","zipcode":null,"country":"Georgia","email":"XXX@yahoo.com","emails":[{"id":31017871539,"value":"XXX@yahoo.com","is_primary":true,"label":null,"_destroy":false}]}}

But I am getting this error

{"errors":{"code":400,"message":["Need to fill this Email to submit the form."]}}

The body of the request is the same that I got from a GET call. Therefore, I know that the key-value pairs are correct. All the values that I am using are unique.

Any idea where the error is? Other GET requests work, so I can connect to the API. TOKEN, XXX, etc are replaced with the actual values in the call.

Thanks
Pietro

I am not sure if you missed it from docs, the Usage of this key is deprecated. Use the emails key to associate emails with a contact. It may be causing this issue.

Could you please share both request and response for GET and POST calls?

Regards,
Thakur

Hello Thakur,
Thanks for your response.
I have removed the “email” key in favour of the “emails” key.
I am still getting the same 400 error.

Here my calls and my responses.

POST

curl -H "Authorization: Token token=<TOKEN>" -H "Content-Type: application/json" -X POST "https://<DOMAIN>.myfreshworks.com/crm/sales/api/contacts" -d '{"contact":{"emails": [{"value":"<EMAIL>@yahoo.com","is_primary":"true","_destroy":"false"}]}}'

The response is:

{"errors":{"code":400,"message":["Need to fill this Email to submit the form."]}}

GET ALL CONTACTS

curl -H "Authorization: Token token=<TOKEN>" -H "Content-Type: application" -X GET "https://<DOMAIN>.myfreshworks.com/crm/sales/api/contacts/view/31000079974"

And this request works fine, returning a list of all contacts.

GET INDIVIDUAL CONTACTS

curl -H "Authorization: Token token=<TOKEN>" -H "Content-Type: application" -X GET "https://<DOMAIN>.myfreshworks.com/crm/sales/api/contacts/31021940186"

This request works fine, too.

Finally, this is the list of all fields for each contact.

{
   "contact" : {
      "active_sales_sequences" : null,
      "address" : null,
      "avatar" : null,
      "city" : "Padova",
      "completed_sales_sequences" : null,
      "country" : "Italia",
      "created_at" : "2023-06-04T11:38:25Z",
      "custom_field" : {
         "cf__wpcf7" : "1162",
         "cf_accademia" : "Pallavolo",
         "cf_certificazioni_linguistiche" : null,
         "cf_checkbox153" : "false",
         "cf_conoscenza" : "Social Media",
         "cf_data_diploma_o_laurea" : null,
         "cf_email_preventivo" : null,
         "cf_esperienze_allestero" : null,
         "cf_facolt_di_interesse" : null,
         "cf_gpa" : null,
         "cf_importanza_aspetto_economico" : null,
         "cf_indirizzo_di_studi" : null,
         "cf_inizio_uni_o_master" : null,
         "cf_interesse" : "Università all'estero",
         "cf_livello_di_inglese" : null,
         "cf_mete_di_interesse" : null,
         "cf_nome_e_cognome_preventivo" : null,
         "cf_programma_di_studi" : null,
         "cf_referenza" : null,
         "cf_scuola_o_universit_frequentata" : null,
         "cf_sicurezza_studio_estero" : null,
         "cf_sport" : null,
         "cf_telefono_preventivo" : null,
         "cf_yourconsent" : "true",
         "cf_yourmessage" : null
      },
      "customer_fit" : 5,
      "display_name" : XXXX,
      "email" : "XXXX@gmail.com",
      "emails" : [
         {
            "_destroy" : false,
            "id" : 31019757301,
            "is_primary" : true,
            "label" : null,
            "value" : "XXXX@gmail.com"
         }
      ],
      "external_id" : null,
      "facebook" : null,
      "first_campaign" : null,
      "first_medium" : null,
      "first_name" : "XXXX",
      "first_seen_chat" : null,
      "first_source" : null,
      "id" : 31021940186,
      "is_deleted" : false,
      "job_title" : null,
      "keyword" : null,
      "last_assigned_at" : null,
      "last_campaign" : null,
      "last_contacted" : null,
      "last_contacted_mode" : null,
      "last_contacted_sales_activity_mode" : null,
      "last_contacted_via_sales_activity" : null,
      "last_medium" : null,
      "last_name" : null,
      "last_seen" : "2023-06-04T12:16:23Z",
      "last_seen_chat" : null,
      "last_source" : null,
      "latest_campaign" : null,
      "latest_medium" : null,
      "latest_source" : null,
      "lead_score" : 81,
      "linkedin" : null,
      "links" : {
         "appointments" : "/crm/sales/contacts/31021940186/appointments?include=creater,owner,updater,targetable,appointment_attendees,conference,note",
         "connections" : "/crm/sales/contacts/31021940186/connections",
         "conversations" : "/crm/sales/contacts/31021940186/conversations/all?include=email_conversation_recipients%2Ctargetable%2Cphone_number%2Cphone_caller%2Cnote%2Cuser&per_page=3",
         "document_associations" : "/crm/sales/contacts/31021940186/document_associations",
         "duplicates" : "/crm/sales/contacts/31021940186/duplicates",
         "notes" : "/crm/sales/contacts/31021940186/notes?include=creater",
         "reminders" : "/crm/sales/contacts/31021940186/reminders?include=creater,owner,updater,targetable",
         "tasks" : "/crm/sales/contacts/31021940186/tasks?include=creater,owner,updater,targetable,users,task_type",
         "timeline_feeds" : "/crm/sales/contacts/31021940186/timeline_feeds"
      },
      "locale" : null,
      "mcr_id" : XXXX,
      "medium" : null,
      "mobile_number" : "XXXX",
      "open_deals_amount" : "0.0",
      "open_deals_count" : 0,
      "other_unsubscription_reason" : null,
      "phone_numbers" : [],
      "recent_note" : null,
      "sms_subscription_status" : 2,
      "state" : null,
      "subscription_status" : 1,
      "subscription_types" : "1;2;3;4;5",
      "system_tags" : [],
      "tags" : [],
      "team_user_ids" : null,
      "time_zone" : null,
      "total_sessions" : null,
      "twitter" : null,
      "unsubscription_reason" : null,
      "updated_at" : "2023-06-05T05:48:02Z",
      "web_form_ids" : null,
      "whatsapp_subscription_status" : 2,
      "won_deals_amount" : "0.0",
      "won_deals_count" : 0,
      "work_email" : null,
      "work_number" : null,
      "zipcode" : "XXXX"
   },
   "meta" : null
}

I have used XXXX to hide all personal information.

Thanks again for your help.

Pietro