> For the complete documentation index, see [llms.txt](https://docs.floral.fun/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.floral.fun/getting-started/quickstart.md).

# Quickstart

This links a user and verifies a like, in four steps. You'll need an application with a redirect URL. See [Create your application](/getting-started/create-application.md). These examples use a confidential client. [Public clients](/authentication/floral-connect.md#client-authentication) leave out the secret and send `client_id` in the body.

## 1. Send the user to Floral

Generate a PKCE verifier and challenge, and a random `state`. Store the verifier and `state` in the user's session on your server:

```javascript
import { createHash, randomBytes } from "node:crypto";

const verifier = randomBytes(32).toString("base64url");
const challenge = createHash("sha256").update(verifier).digest("base64url");
const state = randomBytes(16).toString("base64url");
```

Then redirect the user. This is shown on several lines for reading, but it's one URL:

```
https://api.floral.fun/oauth/authorize
  ?response_type=code
  &client_id=YOUR_CLIENT_ID
  &redirect_uri=https%3A%2F%2Fyourapp.example%2Fcallback
  &scope=profile%3Aread%20quests%3Averify
  &state=RANDOM_STATE
  &code_challenge=BASE64URL_SHA256_OF_VERIFIER
  &code_challenge_method=S256
```

The user signs in on `auth.floral.fun`, or creates an account there, then reviews the request and approves. They return to your `redirect_uri` with `code` and your `state`:

```
https://yourapp.example/callback?code=flr_ac_...&state=RANDOM_STATE
```

Check that `state` matches. If the user cancelled, you'll receive `error=access_denied` instead of a code.

## 2. Exchange the code

Do this from your server within 5 minutes. A code works once.

```bash
curl https://api.floral.fun/oauth/token \
  -u "$CLIENT_ID:$CLIENT_SECRET" \
  -d grant_type=authorization_code \
  -d code="$CODE" \
  -d redirect_uri=https://yourapp.example/callback \
  -d code_verifier="$VERIFIER"
```

```json
{
  "access_token": "flr_at_...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": "profile:read quests:verify",
  "refresh_token": "flr_rt_..."
}
```

## 3. Read the linked profile

```bash
curl https://api.floral.fun/v1/users/me -H "Authorization: Bearer $ACCESS_TOKEN"
```

```json
{
  "id": "usr_6f1c2a90-3b1e-4c55-9d0a-2f7b8e4a1c33",
  "username": "alice",
  "display_name": "Alice",
  "bio": "Building on Floral",
  "avatar_url": "https://cdn.floral.fun/avatars/alice.jpg",
  "is_private": false,
  "is_bot": false,
  "followers_count": 128,
  "following_count": 64,
  "created_at": "2026-01-15T09:30:00.000Z",
  "url": "https://floral.fun/profile/alice"
}
```

Store the returned `id`. It's stable for that Floral account, so use it to stop one account claiming a reward through several of your users.

## 4. Verify an action

`target_id` is the ID of the post. You can copy it from the post's link: in `floral.fun/post/abc123`, it's `abc123`.

```bash
curl https://api.floral.fun/v1/quests/verify \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "like_post",
    "target_id": "post_456",
    "campaign_id": "spring-launch",
    "campaign_start": "2026-11-03T00:00:00Z"
  }'
```

```json
{
  "verified": true,
  "reason": null,
  "action": "like_post",
  "user_id": "usr_123",
  "target_id": "post_456",
  "campaign_id": "spring-launch",
  "completed_at": "2026-11-03T20:00:00.000Z",
  "verification_id": "ver_8f14e45f",
  "first_verified_at": "2026-11-03T20:05:00.000Z",
  "already_verified": false
}
```

`verified` is `false` until the user likes the post. Check for it, and award once, as described in [Preventing duplicate rewards](/api-reference/verification.md#preventing-duplicate-rewards).

## When the access token expires

Access tokens last an hour. When a call returns `401 invalid_token`, [refresh it](/authentication/floral-connect.md#refresh-a-token) and retry. Store the new refresh token each time.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.floral.fun/getting-started/quickstart.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
