# Create a funding account (/docs/api/funding/create-funding-account)

An account the balance is funded through. It is created pending; its payment instructions are available once it is active (event funding_account.active). With amount it is one payment of exactly that amount (collection payment in GET /v1/capabilities): the payer pays the amount and nothing more, and the account closes once it is paid; the pay-in that credits it is payin.completed.

The operation, from the OpenAPI contract (https://docs.caibopay.app/openapi.json):

```json

{
  "method": "POST",
  "path": "/v1/funding-accounts",
  "description": "An account the balance is funded through. It is created pending; its payment instructions are available once it is active (event funding_account.active). With amount it is one payment of exactly that amount (collection payment in GET /v1/capabilities): the payer pays the amount and nothing more, and the account closes once it is paid; the pay-in that credits it is payin.completed.",
  "operationId": "createFundingAccount",
  "parameters": [
    {
      "$ref": "#/components/parameters/IdempotencyKey"
    }
  ],
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/FundingAccountCreate"
        }
      }
    },
    "required": true
  },
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/FundingAccount"
          }
        }
      },
      "description": "The request was already made: the existing resource is returned.",
      "headers": {
        "Idempotent-Replayed": {
          "schema": {
            "enum": [
              "true"
            ],
            "type": "string"
          }
        }
      }
    },
    "201": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/FundingAccount"
          }
        }
      },
      "description": "Created"
    },
    "400": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "The request is not valid."
    },
    "401": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "The API key is missing or not valid."
    },
    "403": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "The API key lacks the required scope."
    },
    "409": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "The Idempotency-Key was used with a different request, or the resource is in conflict."
    },
    "422": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "The request is well formed but cannot be carried out."
    },
    "429": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "Too many requests."
    },
    "500": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "An error on our side. Safe to retry with the same Idempotency-Key."
    },
    "503": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "Temporarily unavailable or suspended. Safe to retry with the same Idempotency-Key."
    }
  },
  "summary": "Create a funding account",
  "tags": [
    "Funding"
  ],
  "x-required-scope": "write",
  "x-codeSamples": [
    {
      "lang": "js",
      "label": "Node.js",
      "source": "import { Caibo } from \"caibopay\";\n\nconst caibo = new Caibo(process.env.CAIBO_API_KEY);\n\nconst result = await caibo.fundingAccounts.create({\n  currency: \"PEN\",\n  method: \"bank_transfer\",\n}, { idempotencyKey: \"your-operation-id\" });"
    },
    {
      "lang": "python",
      "label": "Python",
      "source": "import os\n\nimport caibopay\n\nclient = caibopay.Client(os.environ[\"CAIBO_API_KEY\"])\n\nresult = client.funding_accounts.create(currency=\"PEN\", method=\"bank_transfer\", idempotency_key=\"your-operation-id\")"
    },
    {
      "lang": "go",
      "label": "Go",
      "source": "client, err := caibopay.NewClient(os.Getenv(\"CAIBO_API_KEY\"))\nif err != nil {\n\treturn err\n}\nctx := context.Background()\n\nresult, err := client.FundingAccounts.Create(ctx, &caibopay.FundingAccountCreate{\n\tCurrency: \"PEN\",\n\tMethod: \"bank_transfer\",\n}, caibopay.WithIdempotencyKey(\"your-operation-id\"))\nif err != nil {\n\treturn err\n}\nfmt.Println(result)"
    }
  ]
}

```