---
agentTools:
  projectIndex: https://developers.commerce.busha.co/llms.txt
---

# Create an invoice

This creates an invoice resource.

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Commerce",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.commerce.busha.co"
    }
  ],
  "security": [
    {}
  ],
  "paths": {
    "/invoices": {
      "post": {
        "summary": "Create an invoice",
        "description": "This creates an invoice resource.",
        "operationId": "create-an-invoice",
        "parameters": [
          {
            "name": "X-BC-API-KEY",
            "in": "header",
            "description": "Your business secret key",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name",
                  "customer_email",
                  "local_amount",
                  "customer_name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "name of invoice"
                  },
                  "customer_email": {
                    "type": "string",
                    "description": "recipient email"
                  },
                  "local_amount": {
                    "type": "number",
                    "description": "amount in local currency",
                    "format": "float"
                  },
                  "local_currency": {
                    "type": "string",
                    "description": "currency of invoice"
                  },
                  "customer_name": {
                    "type": "string",
                    "description": "recipient name"
                  },
                  "description": {
                    "type": "string",
                    "description": "invoice description"
                  },
                  "due_date": {
                    "type": "string",
                    "description": "due_date can be passed if the invoice should be cancelled after a certain date",
                    "format": "date"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\n    \"status\": \"success\",\n    \"message\": \"invoice created successfully\",\n    \"data\": {\n        \"id\": \"019b9193-506a-4b5a-a640-1dbea89d4af0\",\n        \"business_id\": \"169c9ff2-4af1-4115-a7eb-363827022624\",\n        \"name\": \"The Sovereign Individual\",\n        \"description\": \"Mastering the Transition to the Information Age\",\n        \"customer_name\": \"Sarah Shaw\",\n        \"customer_email\": \"sarah.shaw@example.co\",\n        \"local_amount\": \"100\",\n        \"local_currency\": \"NGN\",\n        \"status\": \"NEW\",\n        \"reference\": \"INV_Z5MN8QAJpE\",\n        \"created_at\": \"2023-02-24T14:06:16.91137+01:00\",\n        \"updated_at\": \"2023-02-24T14:06:16.91137+01:00\",\n        \"due_date\": null\n    }\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "success"
                    },
                    "message": {
                      "type": "string",
                      "example": "invoice created successfully"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "example": "019b9193-506a-4b5a-a640-1dbea89d4af0"
                        },
                        "business_id": {
                          "type": "string",
                          "example": "169c9ff2-4af1-4115-a7eb-363827022624"
                        },
                        "name": {
                          "type": "string",
                          "example": "The Sovereign Individual"
                        },
                        "description": {
                          "type": "string",
                          "example": "Mastering the Transition to the Information Age"
                        },
                        "customer_name": {
                          "type": "string",
                          "example": "Sarah Shaw"
                        },
                        "customer_email": {
                          "type": "string",
                          "example": "sarah.shaw@example.co"
                        },
                        "local_amount": {
                          "type": "string",
                          "example": "100"
                        },
                        "local_currency": {
                          "type": "string",
                          "example": "NGN"
                        },
                        "status": {
                          "type": "string",
                          "example": "NEW"
                        },
                        "reference": {
                          "type": "string",
                          "example": "INV_Z5MN8QAJpE"
                        },
                        "created_at": {
                          "type": "string",
                          "example": "2023-02-24T14:06:16.91137+01:00"
                        },
                        "updated_at": {
                          "type": "string",
                          "example": "2023-02-24T14:06:16.91137+01:00"
                        },
                        "due_date": {}
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "400",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          },
          "401": {
            "description": "401",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\n  \"error\": {\n    \"name\": \"unauthorized\",\n    \"message\": \"Invalid Authentication\"\n  }\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "example": "unauthorized"
                        },
                        "message": {
                          "type": "string",
                          "example": "Invalid Authentication"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "deprecated": false,
        "x-readme": {
          "code-samples": [
            {
              "language": "curl",
              "code": "curl --location 'https://api.commerce.busha.co/invoices' \\\n--header 'X-BC-API-KEY: {SECRET_API_KEY}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '      { \n        \"name\": \"The Sovereign Individual\",\n        \"customer_email\": \"sarah.shaw@example.co\",\n        \"local_amount\": \"100.00\",\n        \"local_currency\": \"NGN\",\n        \"customer_name\": \"Sarah Shaw\",\n        \"description\": \"Mastering the Transition to the Information Age\"\n      }'"
            },
            {
              "language": "go",
              "code": "package main\n\nimport (\n  \"fmt\"\n  \"strings\"\n  \"net/http\"\n  \"io/ioutil\"\n)\n\nfunc main() {\n\n  url := \"https://api.commerce.busha.co/invoices\"\n  method := \"POST\"\n\n  payload := strings.NewReader(`      { \n        \"name\": \"The Sovereign Individual\",\n        \"customer_email\": \"sarah.shaw@example.co\",\n        \"local_amount\": \"100.00\",\n        \"local_currency\": \"NGN\",\n        \"customer_name\": \"Sarah Shaw\",\n        \"description\": \"Mastering the Transition to the Information Age\"\n      }`)\n\n  client := &http.Client {\n  }\n  req, err := http.NewRequest(method, url, payload)\n\n  if err != nil {\n    fmt.Println(err)\n    return\n  }\n  req.Header.Add(\"X-BC-API-KEY\", \"{SECRET_API_KEY}\")\n  req.Header.Add(\"Content-Type\", \"application/json\")\n\n  res, err := client.Do(req)\n  if err != nil {\n    fmt.Println(err)\n    return\n  }\n  defer res.Body.Close()\n\n  body, err := ioutil.ReadAll(res.Body)\n  if err != nil {\n    fmt.Println(err)\n    return\n  }\n  fmt.Println(string(body))\n}"
            },
            {
              "language": "javascript",
              "code": "var myHeaders = new Headers();\nmyHeaders.append(\"X-BC-API-KEY\", \"{SECRET_API_KEY}\");\nmyHeaders.append(\"Content-Type\", \"application/json\");\n\nvar raw = JSON.stringify({\n  \"name\": \"The Sovereign Individual\",\n  \"customer_email\": \"sarah.shaw@example.co\",\n  \"local_amount\": \"100.00\",\n  \"local_currency\": \"NGN\",\n  \"customer_name\": \"Sarah Shaw\",\n  \"description\": \"Mastering the Transition to the Information Age\"\n});\n\nvar requestOptions = {\n  method: 'POST',\n  headers: myHeaders,\n  body: raw,\n  redirect: 'follow'\n};\n\nfetch(\"https://api.commerce.busha.co/invoices\", requestOptions)\n  .then(response => response.text())\n  .then(result => console.log(result))\n  .catch(error => console.log('error', error));"
            },
            {
              "language": "php",
              "code": "<?php\n\n$curl = curl_init();\n\ncurl_setopt_array($curl, array(\n  CURLOPT_URL => 'https://api.commerce.busha.co/invoices',\n  CURLOPT_RETURNTRANSFER => true,\n  CURLOPT_ENCODING => '',\n  CURLOPT_MAXREDIRS => 10,\n  CURLOPT_TIMEOUT => 0,\n  CURLOPT_FOLLOWLOCATION => true,\n  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n  CURLOPT_CUSTOMREQUEST => 'POST',\n  CURLOPT_POSTFIELDS =>'      { \n        \"name\": \"The Sovereign Individual\",\n        \"customer_email\": \"sarah.shaw@example.co\",\n        \"local_amount\": \"100.00\",\n        \"local_currency\": \"NGN\",\n        \"customer_name\": \"Sarah Shaw\",\n        \"description\": \"Mastering the Transition to the Information Age\"\n      }',\n  CURLOPT_HTTPHEADER => array(\n    'X-BC-API-KEY: {SECRET_API_KEY}',\n    'Content-Type: application/json'\n  ),\n));\n\n$response = curl_exec($curl);\n\ncurl_close($curl);\necho $response;\n"
            }
          ],
          "samples-languages": [
            "curl",
            "go",
            "javascript",
            "php"
          ]
        }
      }
    }
  },
  "x-readme": {
    "headers": [],
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "x-readme-fauxas": true,
  "_id": "63f94c2f2017a0005783edff:63fb4fb15d7258007b04fc91"
}
```