Create a media object
Creates the media object in the pending state and returns it with the upload instruction; URL, method, and headers; for putting its bytes into storage.
POST
Creates the media object in the pending state and returns it with the upload instruction — URL, method, and headers — for putting its bytes into storage. Requires messages:create, or email:send for attachment media.
apiKeyheader
x-api-key<token>application/json- body
filename*stringLength
1 <= length <= 255contentType*stringLength
1 <= length <= 127sizeBytes*integerRange
0 < value <= 26214400purpose*stringValue in
"attachment""avatar""whatsapp_media""review_evidence"checksumSha256?string|nullCreatedMedia
application/json- response
id*MediaIdMatch
^media_[0-9a-hjkmnp-tv-z]{16,24}$organizationId*OrganizationIdMatch
^org_[0-9a-hjkmnp-tv-z]{16,24}$status*stringValue in
"pending""uploading""processing""ready""failed""deleted"filename*stringcontentType*stringsizeBytes*numberRange
0 <= valuewidth*|nullheight*|nulldurationMs*|nullpurpose*stringValue in
"attachment""avatar""whatsapp_media""review_evidence"checksumSha256*string|nullexpiresAt*string|nullcreatedAt*stringconfirmedAt*string|nullupload*import { createClient } from "samva";
const samva = createClient({ apiKey: process.env.SAMVA_API_KEY! });
const result = await samva.media.create({
"filename": "example",
"contentType": "example",
"sizeBytes": 1,
"purpose": "attachment"
});Example Response
{
"id": "string",
"organizationId": "string",
"status": "pending",
"filename": "string",
"contentType": "string",
"sizeBytes": 0,
"width": 1,
"height": 1,
"durationMs": 0,
"purpose": "attachment",
"checksumSha256": "string",
"expiresAt": "string",
"createdAt": "string",
"confirmedAt": "string",
"upload": {
"url": "string",
"method": "PUT",
"headers": {
"property1": "string",
"property2": "string"
},
"expiresAt": "string"
}
}