IMPLEMENTATION-direct-http-api.mdā¢2.41 kB
# Task: Direct HTTP API Implementation
**Priority**: Critical š“
**Assignee**: Claude Code
**Created**: June 28, 2025
**Status**: Ready to Execute
## Objective
Implement direct HTTP API calls to replace browser automation, enabling natural language ā composition creation via REST API.
## Validated API Specifications
### Composition Save Endpoint
```
PUT https://api.digitalpages.com.br/storage/v1.0/content?uid={UID}&manual_project_uid=36c92686-c494-ec11-a22a-dc984041c95d
```
### Request Format
```
Content-Type: multipart/form-data
Authorization: Bearer {JWT_TOKEN}
Content-Disposition: form-data; name="file"; filename="composition.rdpcomposer"
Content-Type: digitalpages/composer
{JSON_PAYLOAD}
```
### JSON Payload Structure
```json
{
"version": "1.1",
"metadata": {
"title": "Composition Title",
"description": "",
"thumb": null,
"tags": []
},
"interface": {
"content_language": "pt_br",
"index_option": "buttons",
"font_family": "Lato",
"show_summary": "disabled",
"finish_btn": "disabled"
},
"structure": [
{
"id": "generated-uuid",
"type": "text-1",
"content": "<p>Widget content</p>",
"background_color": "#FFFFFF",
"padding_top": 0,
"padding_bottom": 0
}
]
}
```
## Implementation Requirements
### Update MCP Server Functions
- `create-new-composition`: Use POST/PUT to storage API
- `edit-composition-metadata`: Update metadata in JSON
- `save-composition`: Use discovered endpoint
- Remove all browser automation dependencies
### Constants
```javascript
const API_BASE = "https://api.digitalpages.com.br";
const PROJECT_UID = "36c92686-c494-ec11-a22a-dc984041c95d";
const JWT_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...";
```
### Widget Type Mapping
- Text: `type: "text-1"`
- Header: `type: "head-1"`
- List: `type: "list-1"`
- Image: `type: "image-1"`
## Success Criteria
- ā
Composition creation via HTTP POST
- ā
Widget addition through structure array
- ā
Natural language ā composition workflow
- ā
EROFS browser automation bypassed
- ā
End-to-end testing successful
## Files to Create/Update
- `/src/api-client.js` - HTTP API client
- `/src/composition-manager.js` - Composition CRUD
- Update existing MCP server functions
- `/tests/direct-api-test.js` - Integration tests
**Ready for immediate implementation with validated API specifications.**