Introduction

The Happyoffer API provides a set of endpoints to manage clients and their contacts within a company. These endpoints allow users to retrieve, create, update, and store client and contact information, ensuring that the data is associated with the correct company. Each request verifies that the company_id of the user performing the request matches the company_id of the client or contact being accessed or modified. This ensures data integrity and security, allowing companies to effectively manage their client relationships and contact information.


GET/api/companies/{company_id}/clients

Get all clients for a company

This endpoint retrieves all clients associated with a specific company, identified by company_id. The company_id should correspond to the company related to the account performing the request.

Parameters

  • company_id (string): The unique identifier of the company for which the clients are being retrieved.

Example Response

{
  "data": [
    {
      "id": "1",
      "attributes": {
        "user_id": "10",
        "company_name": "Example Company",
        "address": "123 Example Street",
        "house_number": "12A",
        "zip_code": "12345",
        "country": "USA",
        "city": "Example City",
        "phone_number": "+1-234-567-890",
        "website_url": "https://www.example.com",
        "chamber_of_commerce_number": "123456789",
        "email": "info@example.com",
        "logo": "https://storage.example.com/logos/example.png",
        "created_at": "2023-01-01T12:00:00Z",
        "updated_at": "2023-01-02T12:00:00Z"
      },
      "relationships": {
        "user": {
          "id": "10",
          "full_name": "John Doe"
        }
      }
    }
    // More client objects
  ]
}

POST/api/contacts/{client_id}/store

Store contact for a client

This endpoint creates a new contact for a specific client, identified by client_id. The request checks if the company_id of the user performing the request matches the company_id associated with the client_id being passed in.

Parameters

  • client_id (string): The unique identifier of the client for whom the contact is being created.

Request Body

The request body must include the following fields:

  • firstname (string, required): The first name of the contact.
  • lastname (string, required): The last name of the contact.
  • gender (string, required): The gender of the contact.
  • email (string, required): The email address of the contact. Must be a valid email format.
  • email_confirmation (string, required): Confirmation of the email address. Must match the email field.
  • phone_number (string, required): The phone number of the contact.
  • notes (string, optional): Any additional notes about the contact.

Example Request

{
  "firstname": "Jane",
  "lastname": "Doe",
  "gender": "Female",
  "email": "jane.doe@example.com",
  "email_confirmation": "jane.doe@example.com",
  "phone_number": "+1-987-654-3210",
  "notes": "Met at the conference."
}

Example Response

{
  "id": "123",
  "attributes": {
    "client_id": "456",
    "firstname": "Jane",
    "lastname": "Doe",
    "gender": "Female",
    "email": "jane.doe@example.com",
    "email_confirmation": "jane.doe@example.com",
    "phone_number": "+1-987-654-3210",
    "note": "Met at the conference."
  }
}

Notes

  • The company_id of the user performing the request must match the company_id associated with the client_id.
  • Ensure that the client_id provided in the request URL is valid and associated with your account.
  • All required fields must be included in the request body.

PATCH/api/contacts/{contact_id}

Update contact by id

This endpoint retrieves a single contact based on the provided contact ID. The request checks if the contact has a client with a company_id that matches the company_id of the user performing the request.

Parameters

  • contact_id (string): The unique identifier of the contact being retrieved.

Example response

{
  "id": "123",
  "attributes": {
    "client_id": "456",
    "firstname": "Jane",
    "lastname": "Doe",
    "gender": "Female",
    "email": "jane.doe@example.com",
    "email_confirmation": "jane.doe@example.com",
    "phone_number": "+1-987-654-3210",
    "note": "Met at the conference."
  }
}

Notes

  • The company_id of the user performing the request must match the company_id associated with the client_id of the contact.
  • Ensure that the contact_id provided in the request URL is valid and associated with your account.
  • Only a single contact will be returned based on the provided contact_id.

Was this page helpful?