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

# Create a charge

This creates a charge resource.

An optional reference could be passed to the request body to create a charge with a cusotm reference. If a charge exist the passed reference the existing charge is returned.

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Commerce",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.commerce.busha.co"
    }
  ],
  "security": [
    {}
  ],
  "paths": {
    "/charges": {
      "post": {
        "summary": "Create a charge",
        "description": "This creates a charge resource.\n\nAn optional reference could be passed to the request body to create a charge with a cusotm reference. If a charge exist the passed reference the existing charge is returned.",
        "operationId": "create-a-charge",
        "parameters": [
          {
            "name": "X-BC-API-KEY",
            "in": "header",
            "description": "Your business secret API key",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "fixed_price"
                ],
                "properties": {
                  "fixed_price": {
                    "type": "boolean",
                    "default": false
                  },
                  "local_amount": {
                    "type": "string",
                    "description": "the amount in the local currency to be charged"
                  },
                  "local_currency": {
                    "type": "string",
                    "description": "the businesses local currency"
                  },
                  "meta": {
                    "type": "object",
                    "description": "Set of key:value that you can add to a charge, this can be useful for storing additional information to be retrieved later on a charge",
                    "properties": {
                      "email": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      }
                    }
                  },
                  "reference": {
                    "type": "string",
                    "description": "reference could be passed to create a charge with a custom reference, should be between 5 and 100 characters."
                  },
                  "callback_url": {
                    "type": "string",
                    "description": "If the customer does not exit their browser after payment, they will be redirected to this callbackurl after payment"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\n    \"status\": \"success\",\n    \"message\": \"Charge created successfully\",\n    \"data\": {\n        \"business_name\": \"Astro Shop\",\n        \"id\": \"a911d24f-e61b-47c2-a2d3-10534bfdff71\",\n        \"business_id\": \"b1583d58-be07-4e75-85c9-3493fa4026c7\",\n        \"deeplink\": \"https:/busha.page.link/busha_pay/charge/a911d24f-e61b-47c2-a2d3-10534bfdff71\",\n        \"reference\": \"RVA5RLV24\",\n        \"hosted_url\": \"https://pay.busha.co/charges/916f0b11-a31b-4df7-a53e-f1529b5424f1\",\n        \"price_fixed\": true,\n        \"local_currency\": \"NGN\",\n        \"meta\": {\n            \"email\": \"sarah.shaw@example.co\",\n            \"name\": \"Sarah Shaw\"\n        },\n        \"expires_at\": \"2023-04-03T15:01:40.387064+01:00\",\n        \"timeline\": [\n            {\n                \"status\": \"NEW\",\n                \"created_at\": \"2023-04-03T14:01:40.387064+01:00\"\n            }\n        ],\n        \"supported_assets\": [\n            {\n                \"currency_id\": \"BTC\",\n                \"chains\": [],\n                \"name\": \"Bitcoin\"\n            },\n            {\n                \"currency_id\": \"ETH\",\n                \"chains\": [],\n                \"name\": \"Ethereum\"\n            },\n            {\n                \"currency_id\": \"USDT\",\n                \"chains\": [\n                    \"TRX\",\n                    \"ETH\"\n                ],\n                \"name\": \"USD Tether\"\n            }\n        ],\n        \"payment_threshold\": {\n            \"overpayment_absolute_threshold\": \"0\",\n            \"overpayment_relative_threshold\": \"0\",\n            \"underpayment_absolute_threshold\": \"0\",\n            \"underpayment_relative_threshold\": \"0\"\n        },\n        \"payments\": [],\n        \"pricing\": [\n            {\n                \"currency_id\": \"NGN\",\n                \"amount\": \"50000\",\n                \"rate\": \"1\",\n                \"is_local\": true\n            },\n            {\n                \"currency_id\": \"BTC\",\n                \"amount\": \"0.00236569\",\n                \"rate\": \"21135458\",\n                \"is_local\": false\n            },\n            {\n                \"currency_id\": \"ETH\",\n                \"amount\": \"0.03679\",\n                \"rate\": \"1359055.1\",\n                \"is_local\": false\n            },\n            {\n                \"currency_id\": \"USDT\",\n                \"amount\": \"66.836877\",\n                \"rate\": \"748.09\",\n                \"is_local\": false\n            }\n        ],\n        \"addresses\": [\n            {\n                \"currency_id\": \"BTC\",\n                \"chain\": \"BTC\",\n                \"address\": \"2NByHBPGz6ukPysFZSRfDV3cwX5wuhTg94r\",\n                \"label\": \"\",\n                \"memo\": \"\"\n            },\n            {\n                \"currency_id\": \"ETH\",\n                \"chain\": \"ETH\",\n                \"address\": \"0xc3E98303AD77C82719aeE9e15A93ceFF9520AA1e\",\n                \"label\": \"\",\n                \"memo\": \"\"\n            },\n            {\n                \"currency_id\": \"USDT\",\n                \"chain\": \"TRX\",\n                \"address\": \"TANH5M9eseArxNGz6ZQJ3YpivEz5Hb6VMu\",\n                \"label\": \"\",\n                \"memo\": \"\"\n            },\n            {\n                \"currency_id\": \"USDT\",\n                \"chain\": \"ETH\",\n                \"address\": \"0x8E3BcC3D904ACc44DF6400B66F419989a9915897\",\n                \"label\": \"\",\n                \"memo\": \"\"\n            }\n        ],\n        \"local_amount\": \"50000\"\n    }\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "success"
                    },
                    "message": {
                      "type": "string",
                      "example": "Charge created successfully"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "business_name": {
                          "type": "string",
                          "example": "Astro Shop"
                        },
                        "id": {
                          "type": "string",
                          "example": "a911d24f-e61b-47c2-a2d3-10534bfdff71"
                        },
                        "business_id": {
                          "type": "string",
                          "example": "b1583d58-be07-4e75-85c9-3493fa4026c7"
                        },
                        "deeplink": {
                          "type": "string",
                          "example": "https:/busha.page.link/busha_pay/charge/a911d24f-e61b-47c2-a2d3-10534bfdff71"
                        },
                        "reference": {
                          "type": "string",
                          "example": "RVA5RLV24"
                        },
                        "hosted_url": {
                          "type": "string",
                          "example": "https://pay.busha.co/charges/916f0b11-a31b-4df7-a53e-f1529b5424f1"
                        },
                        "price_fixed": {
                          "type": "boolean",
                          "example": true,
                          "default": true
                        },
                        "local_currency": {
                          "type": "string",
                          "example": "NGN"
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "email": {
                              "type": "string",
                              "example": "sarah.shaw@example.co"
                            },
                            "name": {
                              "type": "string",
                              "example": "Sarah Shaw"
                            }
                          }
                        },
                        "expires_at": {
                          "type": "string",
                          "example": "2023-04-03T15:01:40.387064+01:00"
                        },
                        "timeline": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "status": {
                                "type": "string",
                                "example": "NEW"
                              },
                              "created_at": {
                                "type": "string",
                                "example": "2023-04-03T14:01:40.387064+01:00"
                              }
                            }
                          }
                        },
                        "supported_assets": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "currency_id": {
                                "type": "string",
                                "example": "BTC"
                              },
                              "chains": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {}
                                }
                              },
                              "name": {
                                "type": "string",
                                "example": "Bitcoin"
                              }
                            }
                          }
                        },
                        "payment_threshold": {
                          "type": "object",
                          "properties": {
                            "overpayment_absolute_threshold": {
                              "type": "string",
                              "example": "0"
                            },
                            "overpayment_relative_threshold": {
                              "type": "string",
                              "example": "0"
                            },
                            "underpayment_absolute_threshold": {
                              "type": "string",
                              "example": "0"
                            },
                            "underpayment_relative_threshold": {
                              "type": "string",
                              "example": "0"
                            }
                          }
                        },
                        "payments": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {}
                          }
                        },
                        "pricing": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "currency_id": {
                                "type": "string",
                                "example": "NGN"
                              },
                              "amount": {
                                "type": "string",
                                "example": "50000"
                              },
                              "rate": {
                                "type": "string",
                                "example": "1"
                              },
                              "is_local": {
                                "type": "boolean",
                                "example": true,
                                "default": true
                              }
                            }
                          }
                        },
                        "addresses": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "currency_id": {
                                "type": "string",
                                "example": "BTC"
                              },
                              "chain": {
                                "type": "string",
                                "example": "BTC"
                              },
                              "address": {
                                "type": "string",
                                "example": "2NByHBPGz6ukPysFZSRfDV3cwX5wuhTg94r"
                              },
                              "label": {
                                "type": "string",
                                "example": ""
                              },
                              "memo": {
                                "type": "string",
                                "example": ""
                              }
                            }
                          }
                        },
                        "local_amount": {
                          "type": "string",
                          "example": "50000"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "400",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\n    \"error\": {\n        \"name\": \"bad_request\",\n        \"message\": \"currency is not allowed; it must equal the default currency for the business\"\n    }\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "example": "bad_request"
                        },
                        "message": {
                          "type": "string",
                          "example": "currency is not allowed; it must equal the default currency for the business"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "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/charges' \\\n--header 'X-BC-API-KEY: {SECRET_API_KEY}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n    \"local_amount\" : \"50000\",\n    \"local_currency\" : \"NGN\",\n    \"meta\": {\n        \"email\":\"sarah.shaw@example.co\", \n        \"name\" : \"Sarah Shaw\"\n    }\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://staging.api.busha.co/v1/commerce/charges\"\n  method := \"POST\"\n\n  payload := strings.NewReader(`{\n    \"local_amount\" : \"50000\",\n    \"local_currency\" : \"NGN\",\n    \"meta\": {\n        \"email\":\"sarah.shaw@example.co\", \n        \"name\" : \"Sarah Shaw\"\n    }\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  \"local_amount\": \"50000\",\n  \"local_currency\": \"NGN\",\n  \"meta\": {\n    \"email\": \"sarah.shaw@example.co\",\n    \"name\": \"Sarah Shaw\"\n  }\n});\n\nvar requestOptions = {\n  method: 'POST',\n  headers: myHeaders,\n  body: raw,\n  redirect: 'follow'\n};\n\nfetch(\"https://staging.api.busha.co/v1/commerce/charges\", requestOptions)\n  .then(response => response.text())\n  .then(result => console.log(result))\n  .catch(error => console.log('error', error));"
            }
          ],
          "samples-languages": [
            "curl",
            "go",
            "javascript"
          ]
        }
      }
    }
  },
  "x-readme": {
    "headers": [],
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "x-readme-fauxas": true,
  "_id": "63f94c2f2017a0005783edff:63fa6e44db1935000a1809ce"
}
```