# Documents

# List documents

Endpoint to retrieve a list of documents for the authenticated users.

# Request

# Endpoint

https://invoices-backend.ampersand.dev/api/documents

# Method

GET

  • Authorization: Bearer <token>

# Body

No parameters.

# Response

[
    {
        id: 1,
        number: null,
        issued_at: null,
        vat: null,
        total: null,
        due_at: null,
        vendor_id: null,
        posting_account_id: null,
        user_id: 1,
        line_items: null,
        file: "documents\/1\/qIRIvI1HfV3YmCna7HmsAxykbeGWApAztITTRTAI.pdf",
        exported_data: null,
        created_at: "2020-12-08T16:58:58.000000Z",
        updated_at: "2020-12-08T16:58:58.000000Z"
    },
    ...
]

# Get document

Endpoint to retrieve a specific document object.

# Request

# Endpoint

https://invoices-backend.ampersand.dev/api/documents/{document_id}

# Method

GET

# Header

  • Authorization: Bearer <token>

# Body

No parameters.

# Response

{
    id: 1,
    number: null,
    issued_at: null,
    vat: null,
    total: null,
    due_at: null,
    vendor_id: null,
    posting_account_id: null,
    user_id: 1,
    line_items: null,
    exported_data: null,
    created_at: "2020-12-08T16:58:58.000000Z",
    updated_at: "2020-12-08T16:58:58.000000Z",
    files: [
        {
            "id": 1,
            "path": "documents/1/1/uZO7yp13Jshyg1wQW9WLu8JYn3VR56GclccRQZX9.pdf",
            "document_id": 1,
            "created_at": "2021-01-07T12:47:14.000000Z",
            "updated_at": "2021-01-07T12:47:14.000000Z"
        }
    ]
}

# Create document

Endpoint to create a document for the current user.

# Request

# Endpoint

https://invoices-backend.ampersand.dev/api/documents

# Method

POST

# Header

  • Authorization: Bearer <token>
  • Content-Type: multipart/form-data

# Body

  • files[]

# Response

# Success

{
    status_code: 200,
    message: "Document created succesfully!",
    document: {
        id: 1,
        number: null,
        issued_at: null,
        vat: null,
        total: null,
        due_at: null,
        vendor_id: null,
        posting_account_id: null,
        user_id: 1,
        line_items: null,
        exported_data: null,
        created_at: "2020-12-08T16:58:58.000000Z",
        updated_at: "2020-12-08T16:58:58.000000Z",
        files: [
            {
                "id": 1,
                "path": "documents/1/1/uZO7yp13Jshyg1wQW9WLu8JYn3VR56GclccRQZX9.pdf",
                "document_id": 1,
                "created_at": "2021-01-07T12:47:14.000000Z",
                "updated_at": "2021-01-07T12:47:14.000000Z"
            }
        ]
    }
}

# Error

{
    status_code: 500,
    message: "Error creating the document."
}

# Update document

Endpoint to update an existing document.

# Request

# Endpoint

https://invoices-backend.ampersand.dev/api/documents/{document_id}

# Method

PUT

# Header

  • Authorization: Bearer <token>
  • Content-Type: multipart/form-data

# Body

  • number
  • issued_at
  • vat
  • total
  • due_at
  • vendor_id
  • posting_account_id

# Response

# Success

{
    status_code: 200,
    message: "Document updated succesfully!",
    document: {
        id: 1,
        number: null,
        issued_at: null,
        vat: null,
        total: null,
        due_at: null,
        vendor_id: null,
        posting_account_id: null,
        user_id: 1,
        line_items: null,
        exported_data: null,
        created_at: "2020-12-08T16:58:58.000000Z",
        updated_at: "2020-12-08T16:58:58.000000Z",
        files: [
            {
                "id": 1,
                "path": "documents/1/1/uZO7yp13Jshyg1wQW9WLu8JYn3VR56GclccRQZX9.pdf",
                "document_id": 1,
                "created_at": "2021-01-07T12:47:14.000000Z",
                "updated_at": "2021-01-07T12:47:14.000000Z"
            }
        ]
    }
}

# Error

{
    status_code: 500,
    message: "Error updating the document."
}

# Upload file to document

Endpoint to upload a file for specific document.

# Request

# Endpoint

https://invoices-backend.ampersand.dev/api/upload/{document_id}

# Method

POST

# Header

  • Authorization: Bearer <token>
  • Content-Type: multipart/form-data

# Body

  • file

# Response

# Success

{
    status_code: 200,
    message: "File uploaded succesfully!",
    document: {
        id: 1,
        number: null,
        issued_at: null,
        vat: null,
        total: null,
        due_at: null,
        vendor_id: null,
        posting_account_id: null,
        user_id: 1,
        line_items: null,
        exported_data: null,
        created_at: "2020-12-08T16:58:58.000000Z",
        updated_at: "2020-12-08T16:58:58.000000Z",
        files: [
            {
                "id": 1,
                "path": "documents/1/1/uZO7yp13Jshyg1wQW9WLu8JYn3VR56GclccRQZX9.pdf",
                "document_id": 1,
                "created_at": "2021-01-07T12:47:14.000000Z",
                "updated_at": "2021-01-07T12:47:14.000000Z"
            }
        ]
    }
}

# Error

{
    status_code: 500,
    message: "Error uploading file."
}

# Search documents

Endpoint to search a document by text.

# Request

# Endpoint

https://invoices-backend.ampersand.dev/api/documents/search

# Method

POST

# Header

  • Authorization: Bearer <token>
  • Content-Type: multipart/form-data

# Body

  • search

# Response

[
    {
        id: 1,
        number: null,
        issued_at: null,
        vat: null,
        total: null,
        due_at: null,
        vendor_id: null,
        posting_account_id: null,
        user_id: 1,
        line_items: null,
        file: "documents\/1\/qIRIvI1HfV3YmCna7HmsAxykbeGWApAztITTRTAI.pdf",
        exported_data: null,
        created_at: "2020-12-08T16:58:58.000000Z",
        updated_at: "2020-12-08T16:58:58.000000Z"
    },
    ...
]

# Delete document

Endpoint to delete a document.

# Request

# Endpoint

https://invoices-backend.ampersand.dev/api/documents/{document_id}

# Method

DELETE

# Header

  • Authorization: Bearer <token>

# Body

No parameters.

# Response

# Success

{
    status_code: 200,
    message: "Document deleted succesfully!"
}

# Error

{
    status_code: 500,
    message: "There was an error deleting the document."
}
Last Updated: 1/26/2021, 5:30:27 PM