# Chat

## Stack chat messages and creator notes

> Manage community messages and creator notes on a stack's chat. The \`action\` query parameter selects the sub-operation.<br>

```json
{"openapi":"3.0.3","info":{"title":"Indexify API","version":"0.1.12-beta"},"servers":[{"url":"https://api.indexify.finance","description":"Production"}],"security":[{},{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-KEY","description":"API key with the `ix_` prefix. You can generate an API Key by navigating to Settings -> API Key in the web app. Pass it in the `X-API-KEY` header on every request."}},"schemas":{"ChatMessage":{"type":"object","properties":{"id":{"type":"integer"},"stack_id":{"type":"integer"},"messages":{"type":"string","description":"Message content."},"message_type":{"type":"string","enum":["community","creator_notes"]},"pinned":{"type":"boolean"},"created_at":{"type":"integer","description":"Unix timestamp."},"user":{"type":"object","properties":{"username":{"type":"string"},"avatar":{"type":"string","nullable":true}}}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}}}},"paths":{"/api/chat.php":{"post":{"tags":["Chat"],"summary":"Stack chat messages and creator notes","description":"Manage community messages and creator notes on a stack's chat. The `action` query parameter selects the sub-operation.\n","parameters":[{"name":"action","in":"query","required":true,"schema":{"type":"string","enum":["addMessage","getAll","togglePin"]}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"oneOf":[{"title":"addMessage","type":"object","required":["stack_id","message"],"properties":{"stack_id":{"type":"integer","description":"Stack whose chat to post to."},"message":{"type":"string","minLength":1,"maxLength":1000,"description":"Message body (1-1000 characters). HTML tags are stripped."},"message_type":{"type":"string","enum":["community","creator_notes"],"default":"community","description":"Message type. `creator_notes` is restricted to the stack creator.\n"},"pinned":{"type":"boolean","default":false,"description":"Pin this message (creator_notes only). Unpins any previously pinned note."}}},{"title":"getAll","type":"object","required":["stack_id"],"properties":{"stack_id":{"type":"integer"},"message_type":{"type":"string","enum":["community","creator_notes"],"default":"community"},"page":{"type":"integer","minimum":1,"default":1},"limit":{"type":"integer","minimum":1,"maximum":100,"default":50}}},{"title":"togglePin","type":"object","required":["message_id"],"properties":{"message_id":{"type":"integer","description":"ID of the creator note to pin or unpin."}}}]}}}},"responses":{"200":{"description":"Successful response. Shape varies by action.","content":{"application/json":{"schema":{"oneOf":[{"title":"AddMessageResponse","type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"object","properties":{"id":{"type":"integer"},"stack_id":{"type":"integer"},"messages":{"type":"string","description":"The message content."},"message_type":{"type":"string","enum":["community","creator_notes"]},"pinned":{"type":"boolean"},"created_at":{"type":"integer","description":"Unix timestamp."},"user":{"type":"object","properties":{"id":{"type":"integer"},"username":{"type":"string"},"avatar":{"type":"string","nullable":true}}}}}}},{"title":"GetAllResponse","type":"object","properties":{"success":{"type":"boolean"},"messages":{"type":"array","items":{"$ref":"#/components/schemas/ChatMessage"}},"pagination":{"type":"object","properties":{"page":{"type":"integer"},"limit":{"type":"integer"},"total":{"type":"integer"},"total_pages":{"type":"integer"},"has_next":{"type":"boolean"},"has_prev":{"type":"boolean"}}},"message_type_supported":{"type":"boolean"},"pinned_notes":{"type":"array","nullable":true,"description":"Only present when message_type is creator_notes. Contains pinned creator notes outside pagination.\n","items":{"$ref":"#/components/schemas/ChatMessage"}}}},{"title":"TogglePinResponse","type":"object","properties":{"success":{"type":"boolean"},"message_id":{"type":"integer"},"pinned":{"type":"boolean"}}}]}}}},"400":{"description":"Validation error (missing fields, message too long/short, etc.).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden (not the stack creator for creator_notes / togglePin).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Chat or message not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal server error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```
