# Event API Reference

Track user registration events and get real-time fraud analysis

## Base URL

All API requests should be made to the following base URL

`https://api.trueguard.io/v2`

## Authentication

All API requests require authentication using your secret API key

**Security Note:** Never expose your secret API key in client-side code. Only use it in your backend services.

#### Required Header

`x-api-key: YOUR_SECRET_API_KEY`

## Endpoints

Track user registration events and get real-time fraud analysis

### Registration Attempt Event

#### POST

/event

Track registration attempts before they complete. This helps you spot suspicious activity early and prevent unwanted accounts from cluttering your database.

#### Registration Attempt Request

```javascript
import axios from 'axios';

const response = await axios.post(
  "https://api.trueguard.io/v2/event",
  {
      action: "register",
      status: "attempt",
      verificationId: "550e8400-e29b-41d4-a716-446655440000",
      context: {
        ip: "192.168.1.1",
        email: "user@example.com",
        phone: "+1234567890",
      },
      metadata: {
        source: "web",
        referrer: "https://example.com",
      },
  },
  {
      headers: {
        "x-api-key": "YOUR_SECRET_API_KEY",
      },
  }
);
```

### Registration Success Event

#### POST

/event

Track successful user registrations with complete user data. Returns risk scores and fraud signals for completed registrations.

#### Successful Registration Request

```javascript
import axios from 'axios';

const response = await axios.post(
  "https://api.trueguard.io/v2/event",
  {
      action: "register",
      status: "success",
      verificationId: "550e8400-e29b-41d4-a716-446655440000",
      context: {
        ip: "192.168.1.1",
        email: "user@example.com",
        phone: "+1234567890",
      },
      user: {
        id: "user123",
        email: "user@example.com",
        metadata: {
          firstName: "John",
          lastName: "Doe",
        },
        attachAttemptEvents: true,
      },
      metadata: {
        source: "web",
        type: "password",
      },
  },
  {
      headers: {
        "x-api-key": "YOUR_SECRET_API_KEY",
      },
  }
);
```

## Error Handling

Understanding and handling API error responses

#### HTTP Status Codes

- **400**  Bad Request - Invalid request format or missing required fields
- **401**  Unauthorized - Invalid or missing API key
- **429**  Too Many Requests - Rate limit or quota exceeded
- **500**  Internal Server Error - Something went wrong on our end

## Need help with integration?

Check out our quick start guide or reach out to our support team for assistance with implementing the Event API.

[Quick Start Guide](/content/docs/index.html) [Contact Support](mailto:info@trueguard.io)
