# Error "Missing required parameter: 'role'" when sending a message to a thread via OpenAI API

**URL:** <https://community.openai.com/t/error-missing-required-parameter-role-when-sending-a-message-to-a-thread-via-openai-api/989022>\
**Category:** API\
**Tags:** assistants-api\
**Created:** [October 23, 2024, 1:52am UTC](https://community.openai.com/t/error-missing-required-parameter-role-when-sending-a-message-to-a-thread-via-openai-api/989022 "2024-10-23T01:52:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![snt.pro.2010](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/snt.pro.2010/32/485210_2.png) [@snt.pro.2010](https://community.openai.com/u/snt.pro.2010)\
**Post date:** [October 23, 2024, 1:52am UTC](https://community.openai.com/t/error-missing-required-parameter-role-when-sending-a-message-to-a-thread-via-openai-api/989022/1 "2024-10-23T01:52:49Z")

</div>

Hi! I’m encountering an issue when trying to send a message to a thread using the OpenAI API. I’m using the following URL for my POST request:

…/v1/threads/thread\_Nz3FCZlsQxb11zcOzB38UQcf/messages

```auto
{
  "messages": [
    {
      "role": "user",
      "content": "How does AI work?"
    }
  ]
}

```

However, I keep getting a `400 Bad Request` error with the following message: ```  
“Missing required parameter: ‘role’”  
I’ve double-checked that the `role` parameter is correctly set to `"user"`, and the `content` field is properly formatted. I also ensured that the headers, including `Authorization` and `Content-Type`, are set correctly. I’ve tried simplifying the request and removing unnecessary characters, but the error persists.  
**Question** :  
Are there any specific details or requirements I might be missing when sending messages to a thread via the OpenAI API? Could there be any new constraints or mandatory parameters that I overlooked?

---

<div class="post-metadata">

**Author:** ![juzarantri786](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/juzarantri786/32/450796_2.png) [@juzarantri786](https://community.openai.com/u/juzarantri786)\
**Post date:** [October 23, 2024, 7:33am UTC](https://community.openai.com/t/error-missing-required-parameter-role-when-sending-a-message-to-a-thread-via-openai-api/989022/2 "2024-10-23T07:33:02Z")

</div>

You should only be passing role and content in the body.

Wrong ❌

```auto
{
  "messages": [
    {
      "role": "user",
      "content": "How does AI work?"
    }
  ]
}

```

Correct ✅

```auto
{
      "role": "user",
      "content": "How does AI work?"
    }

```

---

<div class="post-metadata">

**Author:** ![snt.pro.2010](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/snt.pro.2010/32/485210_2.png) [@snt.pro.2010](https://community.openai.com/u/snt.pro.2010)\
**Post date:** [October 25, 2024, 3:09am UTC](https://community.openai.com/t/error-missing-required-parameter-role-when-sending-a-message-to-a-thread-via-openai-api/989022/3 "2024-10-25T03:09:49Z")

</div>

Hi. Thanks for the tip. Could you also help me figure out how to get a response from the assistant to a specific query?

---

<div class="post-metadata">

**Author:** ![juzarantri786](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/juzarantri786/32/450796_2.png) [@juzarantri786](https://community.openai.com/u/juzarantri786)\
**Post date:** [October 25, 2024, 6:47am UTC](https://community.openai.com/t/error-missing-required-parameter-role-when-sending-a-message-to-a-thread-via-openai-api/989022/4 "2024-10-25T06:47:34Z")

</div>

Hey lets connect over my mail. So that i can guide you properly.
