Add attachments using the API

The Bugify API Explorer doesn't allow you to upload attachments, so to give you an idea, below is some example PHP code to upload multiple attachments to an issue.

<?php

$fields = array(
    'attachment[1]' => '@/path/to/file1',
    'attachment[2]' => '@/path/to/file2',
    'method'        => 'addattachment',
);

$apiKey = 'YOUR-API-KEY';

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $apiKey.':'); 
curl_setopt($ch, CURLOPT_URL, 'http://bugify.example.com/api/issues/123.txt');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);

$result = curl_exec($ch);

print_r($result);

Note that when adding attachments using cURL in PHP, the @ is very important in the path to the file(s).

For any API request, you can specify the API Key as a parameter in $fields called api_key (rather than using CURLOPT_USERPWD - it's up to you).