Files
You can add external files to Invoiced through the API and attach them to invoices. The File Attachments Guide details the entire workflow.
File Object
Represents an external file.
Attributes
{
"created_at": 1464625855,
"id": 13,
"name": "logo-invoice.png",
"object": "file",
"size": 6936,
"type": "image/png",
"updated_at": 1464625855,
"url": "https://invoiced.com/img/logo-invoice.png"
}
Parameter | Type | Description |
---|---|---|
id | integer | The file's unique ID |
object | string | Object type, file |
name | string | Filename |
size | int | File size in bytes |
type | string | MIME type |
url | string | File URL |
created_at | timestamp | Timestamp when created |
updated_at | timestamp | Timestamp when updated |
Create a file
curl "https://api.invoiced.com/files" \
-u {API_KEY}: \
-d url="https://invoiced.com/img/logo-invoice.png" \
-d name="logo-invoice.png" \
-d size=6936 \
-d type="image/png"
invoiced.File.create(
:url => "https://invoiced.com/img/logo-invoice.png",
:name => "logo-invoice.png",
:size => 6936,
:type => "image/png"
)
<?php
$invoiced->File->create([
'url' => "https://invoiced.com/img/logo-invoice.png",
'name' => "logo-invoice.png",
'size' => 6936,
'type' => "image/png"
]);
client.File.create(
url="https://invoiced.com/img/logo-invoice.png",
name="logo-invoice.png",
size=6936,
type="image/png"
)
File file = invoiced.newFile();
file.url = "https://invoiced.com/img/logo-invoice.png";
file.size = 6936;
file.name = "logo-invoice.png";
file.type = "image/png";
file.create();
var file = invoiced.NewFile();
file.Url = "https://invoiced.com/img/logo-invoice.png";
file.Size = 6936;
file.Name = "logo-invoice.png";
file.Type = "image/png";
file.Create();
file, err := client.File.Create(&invoiced.FileRequest{
Url: invoiced.String("https://invoiced.com/img/logo-invoice.png"),
Size: invoiced.Int64(6936),
Name: invoiced.String("logo-invoice.png"),
Type: invoiced.String("image/png"),
})
The above command returns JSON structured like this:
{
"created_at": 1464625855,
"id": 13,
"name": "logo-invoice.png",
"object": "file",
"size": 6936,
"type": "image/png",
"updated_at": 1464625855,
"url": "https://invoiced.com/img/logo-invoice.png"
}
Create a new file object with this endpoint.
HTTP Request
POST /files
Attributes
The file should be uploaded as multipart/form-data. The name
parameter on the uploaded part should be file
. Any other parts in the request will be ignored. If a part with name=file
is not supplied then the request will fail.
Retrieve a file
curl "https://api.invoiced.com/files/:id" \
-u {API_KEY}:
file = invoiced.File.retrieve("{FILE_ID}")
<?php
$file = $invoiced->File->retrieve("{FILE_ID}");
file = client.File.retrieve("{FILE_ID}")
File file = invoiced.newFile().retrieve({FILE_ID});
var file = invoice.NewFile().Retrieve({FILE_ID});
file, err := client.File.Retrieve({FILE_ID})
The above command returns JSON structured like this:
{
"created_at": 1464625855,
"id": 13,
"name": "logo-invoice.png",
"object": "file",
"size": 6936,
"type": "image/png",
"updated_at": 1464625855,
"url": "https://invoiced.com/img/logo-invoice.png"
}
This endpoint retrieves a specific file.
HTTP Request
GET /files/:id
Delete a file
curl "https://api.invoiced.com/files/:id" \
-u {API_KEY}: \
-X DELETE
file.delete
<?php
$file->delete();
file.delete()
file.delete();
file.Delete();
err := client.File.Delete({FILE_ID})
The above command returns
204 No Content
This endpoint deletes a specific file.
HTTP Request
DELETE /files/:id