> ## Documentation Index
> Fetch the complete documentation index at: https://docs.brickken.com/llms.txt
> Use this file to discover all available pages before exploring further.

# newInvest

> Invest in an open Security Token Offering on behalf of a registered investor.

Prepares unsigned transactions for making an investment in a Security Token Offering (STO). Use `POST /prepare-transactions` with `method=newInvest`.

The prepared transaction is signed and sent by `investorAddress`, not by the tokenizer.

## Prerequisites

`newInvest` prepares a single `buyToken` transaction and nothing else. It does **not** whitelist the
investor and it does **not** return an `approve` transaction. Everything below must already be true
before you call it.

**1. The investor exists, with a wallet address**

Create the investor with [`whitelist`](https://docs.brickken.com/api-reference/endpoint/prepare-whitelist) or
[`create-kyc-link`](https://docs.brickken.com/api-reference/endpoint/create-kyc-link), passing the wallet address. Verify
with `GET /get-investor-info`: a null `walletAddress` fails the call.

The investor's email must be different from the tokenizer account's email, or no investor record
is created and lookups return `Investor not found`.

**2. The investor's wallet is whitelisted for this token**

Confirm with `GET /get-whitelist-status?tokenSymbol=…&address=…`. Whitelisting is per token, and
the whitelist transaction must be signed, sent, and confirmed — preparing it is not enough.

**3. KYC is approved, or not required**

`GET /get-investor-info` → `complianceStatus` must be `APPROVED` or `NOT_REQUIRED`. In Sandbox,
create the investor with `needKyc: false` and it reads `NOT_REQUIRED` from the start.

**4. The investor approved this offering's escrow**

Use [`approve`](https://docs.brickken.com/api-reference/endpoint/prepare-approve) with the offering's `escrowAddress` as
`spenderAddress`. Allowances are per spender: approving one offering's escrow grants nothing to
another's.

**5. The investor holds enough payment token**

An allowance is a permission, not a balance. Both must cover the investment amount.

**6. The offering is open**

`startDate` must have passed and `endDate` must not have. Check with `GET /get-sto-by-id`.

The amount must also sit within the offering's `minInvestment` and `maxInvestment`.

> [!TIP]
>
> **Testing in Sandbox?** Pass `needKyc: false` and skip identity verification entirely. The KYC flow
> is a Sumsub verification with document upload, not something you need to prove your integration
> works, and every test investor you create without it is one less manual step in your loop.
>
> Rehearse the real KYC flow once before you go live, since `needKyc: false` is rejected in
> production with `needKyc=false is only available in the sandbox environment`.

## How failures surface

The whitelist, the allowance, and the balance are enforced by the contract, not by an API
precondition check — they are caught when the API simulates the transaction. So they come back as
**contract reverts**, not as friendly messages:

| Revert | Meaning |
| - | - |
| `0x3ecda1e8` `IssuanceNotStarted(address)` | The offering has not opened yet. Check the `Z` suffix on the `startDate` you used at `newSto`. |
| `0xaafefe9b` `UserIsNotWhitelisted(address)` | The wallet in the argument is not whitelisted for this token. |
| Panic `0x11` | Arithmetic underflow — a zero or insufficient allowance to this escrow, or not enough payment token in the wallet. |

> [!NOTE]
>
> Compliance is checked before the chain is simulated, so a KYC-ineligible investor always gets a
> plain `400` naming the compliance problem. A revert therefore always means chain state — a
> timestamp, a whitelist entry, an allowance, or a balance — never a compliance verdict.

## Next step

Preparing does not touch the chain. The response gives you `txId` and an array of unsigned `transactions` — you still have to sign and submit them.

**1. Sign every returned transaction**

Sign each entry locally with the wallet that sends the transaction — `signerAddress`, or `investorAddress` for `newInvest` and `claimTokens`. It must be whitelisted by Brickken, and it needs native gas on the target chain.

**2. Submit the signed payloads**

`POST` them to [`/send-transactions`](https://docs.brickken.com/api-reference/endpoint/send) as `{ txId, signedTransactions }` and Brickken broadcasts for you.

If you would rather broadcast yourself, prepare with `executionMode: "client-broadcast"` and confirm afterwards with `{ txId, txHash }` instead.

**3. Poll until it confirms**

Call [`GET /get-transaction-status`](https://docs.brickken.com/api-reference/endpoint/get-transaction-status) with the `txId`. A `pending` status means it is broadcast but not yet mined — do not resubmit.

Full walkthrough: [Tokenize an asset and run an STO](https://docs.brickken.com/api-reference/guides/tokenize-and-run-an-sto.md).

See [Troubleshooting](https://docs.brickken.com/api-reference/guides/troubleshooting.md) for full revert decoding.


## OpenAPI

````yaml api-reference/prepare/newInvest.json POST /prepare-transactions
openapi: 3.1.0
info:
  title: Brickken API V2 - prepare newInvest
  description: >-
    Method-scoped view of `POST /prepare-transactions` for `method=newInvest`.
    The full endpoint, with every supported method and the common request body
    parameters, is documented in `api-reference/openapi.json`.
  version: 2.0.0
servers:
  - url: https://api.sandbox.brickken.com
    description: Sandbox Environment
  - url: https://api.brickken.com
    description: Production Environment
security: []
paths:
  /prepare-transactions:
    post:
      summary: Prepare an STO investment
      description: >-
        Prepares the unsigned `buyToken` transaction that invests payment tokens
        in an ongoing Security Token Offering. This method prepares that
        transaction only: it does not whitelist the investor and it does not
        return an ERC-20 `approve`. The whitelist, the allowance towards the
        offering's escrow, and the investor's payment-token balance must all be
        in place beforehand, and are enforced by the contract during gas
        estimation rather than by an API precondition check.
      operationId: prepare_newInvest
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - method
                - chainId
                - investorAddress
                - investorEmail
                - tokenSymbol
                - investmentAmount
              properties:
                method:
                  type: string
                  example: newInvest
                  enum:
                    - newInvest
                  description: >-
                    Required. Operation to prepare. Must be `newInvest` for this
                    endpoint.
                  default: newInvest
                chainId:
                  type: string
                  description: >-
                    Required. Blockchain network identifier. Hex format is
                    recommended, for example Sepolia `aa36a7`.
                  example: aa36a7
                investorAddress:
                  type: string
                  description: >-
                    Required. Investor wallet address. It is used as the signer
                    and sender of the prepared transaction, and must already be
                    whitelisted for the token and hold both the payment-token
                    balance and an allowance towards the offering's escrow.
                  example: '0x1111111111111111111111111111111111111111'
                  pattern: ^0x[a-fA-F0-9]{40}$
                investorEmail:
                  type: string
                  description: >-
                    Required. Email of the investor. The investor must already
                    exist in Brickken with a wallet address on record, and must
                    be KYC eligible: `complianceStatus` from `GET
                    /get-investor-info` has to be `APPROVED` or `NOT_REQUIRED`.
                    The email must differ from the tokenizer account's email,
                    otherwise no investor record exists and the call returns
                    `Investor not found`.
                  example: investor@example.com
                  format: email
                tokenSymbol:
                  type: string
                  description: Required. Symbol of the token being offered.
                  example: EXMPL
                investmentAmount:
                  type: string
                  description: >-
                    Required. Payment-token amount to invest. It must fall
                    within the offering's minimum and maximum investment. An
                    amount above the wallet's balance, or above its allowance
                    towards the escrow, reverts with Solidity panic `0x11`.
                  example: '1000'
                signerAddress:
                  type: string
                  description: >-
                    Optional and ignored for this method. The prepared
                    transactions are always signed and sent by
                    `investorAddress`.
                  example: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e'
                paymentTokenSymbol:
                  type: string
                  description: >-
                    Optional. Symbol of the payment token used for the
                    investment. If omitted, the chain default payment token is
                    used.
                  example: USDT
              example:
                method: newInvest
                chainId: aa36a7
                investorAddress: '0x1111111111111111111111111111111111111111'
                investorEmail: investor@example.com
                tokenSymbol: EXMPL
                investmentAmount: '1000'
            example:
              method: newInvest
              chainId: aa36a7
              investorAddress: '0x1111111111111111111111111111111111111111'
              investorEmail: investor@example.com
              tokenSymbol: EXMPL
              investmentAmount: '1000'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  transactions:
                    type: array
                    description: Array of unsigned transaction objects ready for signing
                    items:
                      type: object
                      properties:
                        from:
                          type: string
                          description: Sender address
                          example: '0x1234567890abcdef1234567890abcdef12345678'
                        to:
                          type: string
                          description: Recipient address
                          example: '0xabcdef1234567890abcdef1234567890abcdef12'
                        value:
                          type: string
                          description: Transaction value in hex
                          example: '0x00'
                        nonce:
                          type: integer
                          description: Transaction nonce
                          example: 3792
                        chainId:
                          type: integer
                          description: Blockchain network chain ID
                          example: 11155111
                        data:
                          type: string
                          description: Transaction data payload
                          example: >-
                            0xd362e8a70000000000000000000000000000000000000000000000000000000000000040...
                        type:
                          type: integer
                          description: Transaction type (EIP-1559)
                          example: 2
                        maxPriorityFeePerGas:
                          type: string
                          description: Maximum priority fee per gas
                          example: '1150000'
                        maxFeePerGas:
                          type: string
                          description: Maximum fee per gas
                          example: '1156037'
                        gasLimit:
                          type: string
                          description: Gas limit in hex
                          example: '0xccef'
                  info:
                    type: object
                    description: Metadata about the operation
                    properties:
                      tokenizerEmail:
                        type: string
                        description: Email of the tokenizer
                        example: tokenizer@example.com
                      tokenSymbol:
                        type: string
                        description: Symbol of the token
                        example: EXMPL
                      investorEmail:
                        type: string
                        description: Email of the investor (when applicable)
                        example: investor@example.com
                  txId:
                    type: string
                    description: >-
                      Unique identifier for this transaction batch (required for
                      /send-transactions). This is NOT a blockchain transaction
                      hash.
                    example: >-
                      0x46adea7bdf49c576a760102e0d6bc9ecd650b3998588cd3d7f576a7973426aad
                required:
                  - transactions
                  - txId
      security:
        - apiKeyAuth: []
components:
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.