Upload article image
POST https://api.weav.com/v1/kb-articles/{id}/images
Requires a token with the external-api:write ability.
Path parameters
idstringrequiredFormat: uuid.
Body
imagefilerequiredJPEG, PNG, GIF, or WebP image up to 5 MB
Format: binary.
Request
cURL
curl --request POST \
--url 'https://api.weav.com/v1/kb-articles/{id}/images' \
--header "Authorization: Bearer ${WEAV_API_TOKEN}" \
--form 'image=@/path/to/file'
JavaScript
import fs from 'node:fs';
const formData = new FormData();
formData.append('image', await fs.openAsBlob('/path/to/file'), 'file');
const response = await fetch("https://api.weav.com/v1/kb-articles/{id}/images", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.WEAV_API_TOKEN}`
},
body: formData
});
console.log(await response.json());
Python
import os
import requests
headers = {"Authorization": f"Bearer {os.environ['WEAV_API_TOKEN']}"}
files = {"image": open("/path/to/file", 'rb')}
response = requests.post("https://api.weav.com/v1/kb-articles/{id}/images", headers=headers, files=files)
print(response.json())
PHP
use GuzzleHttp\Client;
$client = new Client();
$response = $client->request('POST', 'https://api.weav.com/v1/kb-articles/{id}/images', [
'headers' => ['Authorization' => 'Bearer '.getenv('WEAV_API_TOKEN')],
'multipart' => [
['name' => 'image', 'contents' => fopen('/path/to/file', 'r')]
],
]);
echo $response->getBody();
Response
201 Created
{
"url": "https://example.com",
"key": "string"
}
Response fields
urlstringFormat: uri.
keystring