Skip to main content
POST
/
company_token_transactions
JavaScript
import Whop from '@whop/sdk';

const client = new Whop({
  apiKey: process.env['WHOP_API_KEY'], // This is the default and can be omitted
});

const companyTokenTransaction = await client.companyTokenTransactions.create({
  amount: 6.9,
  company_id: 'biz_xxxxxxxxxxxxxx',
  destination_user_id: 'destination_user_id',
  transaction_type: 'transfer',
  user_id: 'user_xxxxxxxxxxxxx',
});

console.log(companyTokenTransaction.id);
{
  "id": "<string>",
  "transaction_type": "add",
  "amount": 6.9,
  "description": "Reward for completing onboarding",
  "created_at": "2023-12-01T05:00:00.401Z",
  "linked_transaction_id": "<string>",
  "idempotency_key": "txn_reward_usr_123_2024",
  "user": {
    "id": "user_xxxxxxxxxxxxx",
    "name": "John Doe",
    "username": "johndoe42"
  },
  "member": {
    "id": "<string>"
  },
  "company": {
    "id": "biz_xxxxxxxxxxxxxx",
    "title": "<string>",
    "route": "<string>"
  }
}

Authorizations

Authorization
string
header
required

A company API key, company scoped JWT, app API key, or user OAuth token. You must prepend your key/token with the word 'Bearer', which will look like Bearer ***************************

Body

application/json

Autogenerated input type of CreateCompanyTokenTransaction

amount
number
required

The positive number of tokens to transact. For example, 100.0 for 100 tokens.

Example:

6.9

company_id
string
required

The unique identifier of the company to create the transaction in, starting with 'biz_'.

Example:

"biz_xxxxxxxxxxxxxx"

destination_user_id
string
required

The unique identifier of the user receiving the tokens. Required when the transaction type is 'transfer'.

transaction_type
string
required
Allowed value: "transfer"
user_id
string
required

The unique identifier of the user whose token balance will be affected, starting with 'user_'.

Example:

"user_xxxxxxxxxxxxx"

description
string | null

A human-readable description of why the transaction was created.

idempotency_key
string | null

A unique key to prevent duplicate transactions. Use a UUID or similar unique string.

Response

A successful response

A token transaction records a credit or debit to a member's token balance within a company, including transfers between members.

id
string
required

The unique identifier for the company token transaction.

transaction_type
enum<string>
required

The direction of this token transaction (add, subtract, or transfer).

Available options:
add,
subtract,
transfer
amount
number
required

The token amount for this transaction. Always a positive value regardless of transaction type.

Example:

6.9

description
string | null
required

Free-text description explaining the reason for this token transaction. Null if no description was provided.

Example:

"Reward for completing onboarding"

created_at
string<date-time>
required

The datetime the company token transaction was created.

Example:

"2023-12-01T05:00:00.401Z"

linked_transaction_id
string | null
required

The ID of the corresponding transaction on the other side of a transfer. Null if this is not a transfer transaction.

idempotency_key
string | null
required

A unique key used to prevent duplicate transactions when retrying API requests. Null if no idempotency key was provided.

Example:

"txn_reward_usr_123_2024"

user
object
required

The user whose token balance was affected by this transaction.

member
object
required

The member whose token balance was affected by this transaction.

company
object
required

The company whose token balance this transaction affects.