# Demo: Customers vote on a budget

> A retailer sets a yearly budget, 20 000 € for example, and lets customers decide where it goes. Each customer casts one vote on a hosted ballot; the budget is billed at activation.

One variant of **Customers vote on a budget**, in Retail: A yearly budget split by the votes.

A made-up site, your-brand.example/vote, walked through screen by screen with the Charitips API calls the product makes at each step. Rebuild it in your own project to start from a working flow.

The charity choice in this demo is the Charitips [charity selection widget](https://www.charitips.com/docs/widgets/charity_selection.md), a ready-made proposal. Use it whole, use parts of it, or build your own experience from scratch with the API: [List charities](https://www.charitips.com/docs/api-reference/list-charities.md) gives the charities to show, and the calls below carry the chosen `charityId`.

Charitips widget: the charity cards and their profiles. Your own UI, built with the API: the budget, the vote button and the live results.

The full guide, with edge cases: https://www.charitips.com/docs/use-cases/vote-on-a-budget.md.

**Once, before the first customer:**

- [`POST /v1/charities-selections`](https://www.charitips.com/docs/api-reference/create-charities-selection.md) Create a charities selection: once: the charities people can vote for, from the catalog

  ```json
  {
    "name": "Vote 2026",
    "charityIds": [
      "<charityId>"
    ]
  }
  ```
- [`POST /v1/campaigns`](https://www.charitips.com/docs/api-reference/create-campaign.md) Create a campaign: once: a DISTRIBUTION campaign with a fixed budget, billed at activation

  ```json
  {
    "name": "Our 2026 budget",
    "type": "TIME_BASED",
    "endDate": "2026-12-31",
    "donationType": "DISTRIBUTION",
    "amountType": "FIXED_AMOUNT",
    "budget": 2000000,
    "charitiesSelectionId": "<charitiesSelectionId>"
  }
  ```
- [`POST /v1/campaigns/{campaignId}/activate`](https://www.charitips.com/docs/api-reference/activate-campaign.md) Activate a campaign: once: the campaign starts taking votes

## Screens and calls

### 1. We give 20 000 € this year. You decide where.

The ballot opens on the page, in a random order for each customer, with no results before the vote. When the customer confirms, your server creates their vote, then casts it: two taps in all.

- The customer picks a charity from your selection.
- Button: Vote for the charity

**Your server calls:**

- [`POST /v1/votes`](https://www.charitips.com/docs/api-reference/create-vote.md) Create a vote: when the customer confirms, just before casting it: one vote per customer, with its weight

  ```json
  {
    "campaignId": "<campaignId>",
    "uniqueExternalId": "customer_204",
    "weight": 1
  }
  ```

Charitips then sends the `vote_create` webhook to your endpoint.

### 2. Your vote is recorded

- Button: Vote for the charity

**Your server calls:**

- [`POST /v1/votes/{voteId}/cast`](https://www.charitips.com/docs/api-reference/cast-vote.md) Cast a vote: right after create-vote, with its voteId

  ```json
  {
    "charityId": "<charityId>"
  }
  ```

Charitips then sends the `vote_update` webhook to your endpoint.

### 3. You have already voted

The same customer tries again: the API keeps the first vote.

- Button: Simulate a second vote

**Your server calls:**

- [`POST /v1/votes/{voteId}/cast`](https://www.charitips.com/docs/api-reference/cast-vote.md) Cast a vote: the same voteId, cast a second time

  ```json
  {
    "charityId": "<anotherCharityId>"
  }
  ```

## Clone it with a coding agent

```prompt
Clone the Charitips demo "Customers vote on a budget" into this project. Read https://www.charitips.com/docs/demos/vote.md: it lists each screen and the Charitips API calls behind it. Build the same flow in this codebase, on the sandbox (https://api.sandbox.charitips.com), with my client id and secret read from environment variables, and follow the rules of https://www.charitips.com/docs/skill.md. Make every API call from the server, never from the browser. When it works, show me each call and its response.
```

## Variants

**Variants**: the same flow in other sectors, each with its build spec.

- [Customers vote on a budget](https://www.charitips.com/docs/use-cases/vote-on-a-budget/budget-vote.md) (Retail): A retailer sets a yearly budget, 20 000 € for example, and lets customers decide where it goes. Each customer casts one vote on a hosted ballot; the budget is billed at activation. A yearly budget split by the votes. Build spec: https://www.charitips.com/docs/demos/vote.md
- [Visitors vote at an exhibition](https://www.charitips.com/docs/use-cases/vote-on-a-budget/exhibition-ballot.md) (Culture and events): A museum funds a pot of 1 € per ticket for an exhibition. Each ticket is one vote on a screen at the exit; the pot is split by the votes when the exhibition closes. 1 € per ticket, split by the votes. Build spec: https://www.charitips.com/docs/demos/vote/exhibition-ballot.md
- [The tournament winner picks](https://www.charitips.com/docs/use-cases/vote-on-a-budget/tournament-winner.md) (Software and apps): An e-sport league puts 2 € per entry into a charity pot. Players sign up and compete; the tournament winner picks the charity the whole pot goes to; the league pays. 2 € per entry, the winner picks the charity. Build spec: https://www.charitips.com/docs/demos/vote/tournament-winner.md
- [Collective adoption goal](https://www.charitips.com/docs/use-cases/vote-on-a-budget/adoption-goal.md) (Software and apps): A SaaS ties a donation to a feature's adoption: once 500 users have turned it on, it gives 0,50 € per user. Each user picks their own charity. 0,50 € per user, paid once the goal is reached. Build spec: https://www.charitips.com/docs/demos/vote/adoption-goal.md
- [Poll after a webinar](https://www.charitips.com/docs/use-cases/vote-on-a-budget/webinar-poll.md) (Education): A training company gives 5 % of each webinar ticket. When the live session ends, a poll opens and the attendees choose the charity together; the company pays. 5 % of each ticket, the attendees choose. Build spec: https://www.charitips.com/docs/demos/vote/webinar-poll.md
