Upload an image to a post
curl --request PATCH \
--url https://api.yalg.ai/v1/posts/{id}/upload-image \
--header 'Content-Type: multipart/form-data' \
--header 'x-api-key: <api-key>' \
--form image='@example-file'const form = new FormData();
form.append('image', '<image file>');
const options = {method: 'PATCH', headers: {'x-api-key': '<api-key>'}};
options.body = form;
fetch('https://api.yalg.ai/v1/posts/{id}/upload-image', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.yalg.ai/v1/posts/{id}/upload-image"
files = { "image": ("example-file", open("example-file", "rb")) }
headers = {"x-api-key": "<api-key>"}
response = requests.patch(url, files=files, headers=headers)
print(response.text){
"id": "123e4567-e89b-12d3-a456-426614174000",
"content": "Post content...",
"imageUrl": "/uploads/images/1640123456789-example.jpg",
"videoUrl": null,
"authorId": "987fcdeb-51a2-43d7-8f9e-123456789abc",
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:35:00Z"
}{
"statusCode": 400,
"message": "Validation failed",
"error": "Bad Request",
"code": "validation_failed"
}{
"statusCode": 401,
"message": "Invalid or missing API key",
"error": "Unauthorized",
"code": "unauthorized"
}{
"statusCode": 403,
"message": "Access denied",
"error": "Forbidden",
"code": "forbidden"
}{
"statusCode": 404,
"message": "Resource not found",
"error": "Not Found",
"code": "not_found"
}{
"statusCode": 409,
"message": "Resource conflict",
"error": "Conflict",
"code": "conflict"
}{
"statusCode": 429,
"message": "Rate limit exceeded",
"error": "Too Many Requests",
"code": "rate_limit_exceeded",
"retryAfter": 60
}{
"statusCode": 500,
"message": "Internal server error",
"error": "Internal Server Error",
"code": "internal_server_error"
}posts
Upload an image to a post
Upload an image to a post through the YALG API. Requests are scoped to the authenticated API key owner; cross-owner resource IDs return 404.
PATCH
/
v1
/
posts
/
{id}
/
upload-image
Upload an image to a post
curl --request PATCH \
--url https://api.yalg.ai/v1/posts/{id}/upload-image \
--header 'Content-Type: multipart/form-data' \
--header 'x-api-key: <api-key>' \
--form image='@example-file'const form = new FormData();
form.append('image', '<image file>');
const options = {method: 'PATCH', headers: {'x-api-key': '<api-key>'}};
options.body = form;
fetch('https://api.yalg.ai/v1/posts/{id}/upload-image', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.yalg.ai/v1/posts/{id}/upload-image"
files = { "image": ("example-file", open("example-file", "rb")) }
headers = {"x-api-key": "<api-key>"}
response = requests.patch(url, files=files, headers=headers)
print(response.text){
"id": "123e4567-e89b-12d3-a456-426614174000",
"content": "Post content...",
"imageUrl": "/uploads/images/1640123456789-example.jpg",
"videoUrl": null,
"authorId": "987fcdeb-51a2-43d7-8f9e-123456789abc",
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:35:00Z"
}{
"statusCode": 400,
"message": "Validation failed",
"error": "Bad Request",
"code": "validation_failed"
}{
"statusCode": 401,
"message": "Invalid or missing API key",
"error": "Unauthorized",
"code": "unauthorized"
}{
"statusCode": 403,
"message": "Access denied",
"error": "Forbidden",
"code": "forbidden"
}{
"statusCode": 404,
"message": "Resource not found",
"error": "Not Found",
"code": "not_found"
}{
"statusCode": 409,
"message": "Resource conflict",
"error": "Conflict",
"code": "conflict"
}{
"statusCode": 429,
"message": "Rate limit exceeded",
"error": "Too Many Requests",
"code": "rate_limit_exceeded",
"retryAfter": 60
}{
"statusCode": 500,
"message": "Internal server error",
"error": "Internal Server Error",
"code": "internal_server_error"
}Authorizations
YALG Developer API key. Send it in the x-api-key header from a server-side environment only.
Path Parameters
UUID of the post
Example:
"123e4567-e89b-12d3-a456-426614174000"
Body
multipart/form-data
Image file (jpg, png, gif, etc.)
Response
Image uploaded successfully
⌘I