# post\_\_conversation\_{conversationId}\_prompt

{% hint style="info" %}
This API endpoint is currently available only in the TEST environment. It is not yet available in production.
{% endhint %}

`POST /conversation/{conversationId}/prompt`

*Send Prompt to Conversation*

Send a user prompt to an AI conversation. This endpoint processes the prompt through the configured AI provider and returns the assistant's response, maintaining conversation context for multi-turn interactions.

**Key Features:**

* Sends user prompts to the AI conversation engine
* Maintains conversation context across multiple turns
* Integrates with repository AI API keys for authentication
* Enforces AI policies and governance rules
* Tracks token usage and updates conversation statistics
* Returns assistant responses in real-time or streaming format

**Important Notes:**

* Users must have access to the conversation's workspace
* The conversation must exist and not be deleted
* Policy enforcement occurs during prompt processing
* Token usage is automatically tracked and updated
* Responses are subject to policy validation (log, alert, or block)

**Security:**

* Access is validated against workspace permissions
* Only users with workspace read access can send prompts
* Policies are evaluated before and during prompt processing
* Violations are logged and tracked for compliance

**Integration:**

This endpoint integrates with external conversation API engines to process prompts and generate responses. The system handles:

* Routing to the appropriate AI provider
* Context management across conversation turns
* Policy enforcement and violation detection
* Token counting and usage tracking

#### TypeScript Client Library

```typescript
public sendPrompt = async (
  conversationId: string,
  data: SendPromptRequest
): Promise<SendPromptResponse> => {
  return this.makeRequest<SendPromptResponse>(`conversation/${conversationId}/prompt`, 'POST', data);
};
```

#### Code Samples

{% tabs %}
{% tab title="Shell" %}

```shell
# You can also use wget
curl -X POST https://backend.flashback.tech/conversation/{conversationId}/prompt \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer {access-token}'
```

{% endtab %}

{% tab title="HTTP" %}

```http
POST https://backend.flashback.tech/conversation/{conversationId}/prompt HTTP/1.1
Host: backend.flashback.tech
Content-Type: application/json
Accept: application/json
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const inputBody = '{
  "prompt": "What is the best practice for securing API keys?"
}';
const headers = {
  'Content-Type':'application/json',
  'Accept':'application/json',
  'Authorization':'Bearer {access-token}'
};

fetch('https://backend.flashback.tech/conversation/{conversationId}/prompt',
{
  method: 'POST',
  body: inputBody,
  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'rest-client'
require 'json'

headers = {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' => 'Bearer {access-token}'
}

result = RestClient.post 'https://backend.flashback.tech/conversation/{conversationId}/prompt',
  params: {
  }, headers: headers

p JSON.parse(result)
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'Authorization': 'Bearer {access-token}'
}

r = requests.post('https://backend.flashback.tech/conversation/{conversationId}/prompt', headers = headers)

print(r.json())
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

require 'vendor/autoload.php';

$headers = array(
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Authorization' => 'Bearer {access-token}',
);
```

{% endtab %}

{% tab title="Java" %}

```java
URL obj = new URL("https://backend.flashback.tech/conversation/{conversationId}/prompt");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
    new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
    response.append(inputLine);
}
in.close();
System.out.println(response.toString());
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
       "bytes"
       "net/http"
)

func main() {

    headers := map[string][]string{
        "Content-Type": []string{"application/json"},
        "Accept": []string{"application/json"},
        "Authorization": []string{"Bearer {access-token}"},
    }

    data := bytes.NewBuffer([]byte{jsonReq})
    req, err := http.NewRequest("POST", "https://backend.flashback.tech/conversation/{conversationId}/prompt", data)
    req.Header = headers

    client := &http.Client{}
    resp, err := client.Do(req)
    // ...
}
```

{% endtab %}
{% endtabs %}

> Body parameter

```json
{
  "prompt": "What is the best practice for securing API keys?"
}
```

#### Parameters <a href="#post__conversation_-conversationid-_prompt-parameters" id="post__conversation_-conversationid-_prompt-parameters"></a>

| Name           | In   | Type   | Required | Description                           |
| -------------- | ---- | ------ | -------- | ------------------------------------- |
| conversationId | path | string | true     | Unique identifier of the conversation |
| body           | body | object | true     | none                                  |
| » prompt       | body | string | true     | User prompt text to send to the AI    |

> Example responses

> 200 Response

```json
{
  "success": true,
  "message": "Prompt sent successfully"
}
```

#### Responses <a href="#post__conversation_-conversationid-_prompt-responses" id="post__conversation_-conversationid-_prompt-responses"></a>

| Status | Meaning                                                                    | Description                       | Schema |
| ------ | -------------------------------------------------------------------------- | --------------------------------- | ------ |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)                    | Prompt sent successfully          | Inline |
| 400    | [Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)           | Validation error or invalid input | Inline |
| 403    | [Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)             | Insufficient permissions          | Inline |
| 404    | [Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)             | Conversation not found            | Inline |
| 500    | [Internal Server Error](https://tools.ietf.org/html/rfc7231#section-6.6.1) | Failed to send prompt             | Inline |

#### Response Schema <a href="#post__conversation_-conversationid-_prompt-responseschema" id="post__conversation_-conversationid-_prompt-responseschema"></a>

Status Code **200**

| Name      | Type    | Required | Restrictions | Description              |
| --------- | ------- | -------- | ------------ | ------------------------ |
| » success | boolean | false    | none         | Operation success status |
| » message | string  | false    | none         | Success message          |

**Note:** Additional response fields may be added when the external API integration is fully implemented, such as response content, token counts, model information, and streaming metadata.

Status Code **400**

| Name      | Type    | Required | Restrictions | Description   |
| --------- | ------- | -------- | ------------ | ------------- |
| » success | boolean | false    | none         | none          |
| » message | string  | false    | none         | Error message |

Status Code **403**

| Name      | Type    | Required | Restrictions | Description   |
| --------- | ------- | -------- | ------------ | ------------- |
| » success | boolean | false    | none         | none          |
| » message | string  | false    | none         | Error message |

Status Code **404**

| Name      | Type    | Required | Restrictions | Description   |
| --------- | ------- | -------- | ------------ | ------------- |
| » success | boolean | false    | none         | none          |
| » message | string  | false    | none         | Error message |

Status Code **500**

| Name      | Type    | Required | Restrictions | Description   |
| --------- | ------- | -------- | ------------ | ------------- |
| » success | boolean | false    | none         | none          |
| » message | string  | false    | none         | Error message |

To perform this operation, you must be authenticated by means of one of the following methods: BearerAuth


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.flashback.tech/support-reference/platform-api-reference/conversation-api/post__conversation_-conversationid-_prompt.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
