Upload an attachment to a risk
const url = 'https://api.adversarial.com/api/v1/risks/RSK-00001/attachments';const form = new FormData();form.append('file', 'file');
const options = {method: 'POST'};
options.body = form;
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.adversarial.com/api/v1/risks/RSK-00001/attachments \ --header 'Content-Type: multipart/form-data' \ --form file=@fileSend the file as multipart form data in a single part named file.
Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The ID of the risk — RSK-00001 (case-insensitive) or a bare number
Example
RSK-00001Request Bodyrequired
Section titled “Request Bodyrequired”The multipart body of an attachment upload.
Exactly one part, named file, carrying the raw bytes and a filename; a
missing filename is refused with 400. The part’s declared content type must
be one of the types in allowed_content_types (PDF, DOCX, XLSX, PPTX, PNG,
JPEG, CSV, plain text, Markdown, JSON), and the filename’s extension must
match that type (.pdf, .docx, .xlsx, .pptx, .png, .jpg, .jpeg,
.csv, .txt, .text, .md, .markdown or .json). PDF, image, and
Office files must carry the expected leading signature. CSV, plain-text,
Markdown, and JSON files must contain no NUL byte;
this is a coarse binary-file guard and does not validate encoding, CSV
structure, or JSON syntax. A failed content check is refused with 415. A
CSV declared as application/vnd.ms-excel is stored as text/csv. The
file’s own bytes must be at most 25 MiB, or the request is refused with 413.
object
The file to attach.
Responses
Section titled “Responses”Attachment stored
A file attached to a risk, an incident, or a comment on either.
Embedded in the attachments list of the record it is attached to, and
returned when a file is uploaded to a risk or incident.
object
File size in bytes.
MIME content type.
The user who uploaded the file, if known. On a comment’s attachments this can differ from the comment’s author: a comment may reference a file someone else uploaded to the same record.
When the file was uploaded.
The attachment’s id; download it with GET /v1/files/{id}.
Original file name as uploaded.
The file’s upload status. Attachments are only listed once their upload
has finished, so this is always ready.
Example
{ "status": "pending"}Missing or malformed multipart upload
Missing risks:write permission
Risk not found
Upload exceeds the maximum allowed size
Content type not permitted, or the file name’s extension or the file’s contents do not match it