> ## Documentation Index
> Fetch the complete documentation index at: https://apidoc.fax.plus/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a contact

> Create a new contact (Permitted scopes: **fax:all:edit**)

<RequestExample>
  ```js NodeJS SDK theme={null}
  const axios = require('axios');
  const ContactsApiFp = require('@alohi/faxplus-api').ContactsApiFp;
  const Configuration = require('@alohi/faxplus-api').Configuration;

  const config = new Configuration({
      accessToken: accessToken,
      basePath: 'https://restapi.fax.plus/v3',
      // Header required only when using the OAuth2 token scheme
      baseOptions: {
          headers: {
            "x-fax-clientid": clientId,
          }
      }
  });

  async function createContact() {
      const contactData = {
          name: 'John Doe',
          company: 'Acme Corp',
          numbers: ['+1234567890'],
          emails: ['john@example.com'],
          address: '123 Main St',
          notes: 'Important client'
      };
      const req = await ContactsApiFp(config).createContact({
          userId: 'self',
          body: contactData
      });
      const resp = await req(axios);
  }

  createContact()
  ```

  ```python Python SDK theme={null}
  from faxplus import ApiClient, ContactsApi
  from faxplus.configuration import Configuration

  conf = Configuration()
  conf.access_token = access_token
  # header_name and header_value required only when using the OAuth2 token scheme
  api_client = ApiClient(header_name='x-fax-clientid', header_value=client_id, configuration=conf)
  api = ContactsApi(api_client)

  contact_data = {
      'name': 'John Doe',
      'company': 'Acme Corp',
      'numbers': ['+1234567890'],
      'emails': ['john@example.com'],
      'address': '123 Main St',
      'notes': 'Important client'
  }

  resp = api.create_contact(user_id='self', body=contact_data)
  ```

  ```java Java theme={null}
  /**
   * Example below uses Apache HTTP Client 4 with Fluent API
   **/

  String url = "https://restapi.fax.plus/v3/accounts/self/contacts";

  String jsonBody = "{\"name\":\"John Doe\",\"company\":\"Acme Corp\",\"numbers\":[\"+1234567890\"],\"emails\":[\"john@example.com\"],\"address\":\"123 Main St\",\"notes\":\"Important client\"}";

  String result = Request
      .Post(url)
       // The x-fax-clientid header is required only when using the OAuth2 token scheme
      .addHeader("x-fax-clientid", "YOUR_CLIENT_ID")
      .addHeader("Content-Type", "application/json")
      .addHeader("Accept", "'application/json'")
      .addHeader("Authorization", "'Bearer {access-token}'")
      .bodyString(jsonBody, ContentType.APPLICATION_JSON)
      .execute()
      .returnContent().asString();

  System.out.println(result.toString());
  ```

  ```go Go theme={null}
  package main

  import (
         "bytes"
         "net/http"
  )

  func main() {

      headers := map[string][]string{
          // The x-fax-clientid header is required only when using the OAuth2 token scheme
          "Content-Type": []string{"application/json"},
          "Accept": []string{"application/json"},
          "Authorization": []string{"Bearer {access-token}"},
          "x-fax-clientid": []string{"YOUR_CLIENT_ID"}
      }

      jsonBody := []byte(`{"name":"John Doe","company":"Acme Corp","numbers":["+1234567890"],"emails":["john@example.com"],"address":"123 Main St","notes":"Important client"}`)
      data := bytes.NewBuffer(jsonBody)
      req, err := http.NewRequest("POST", "https://restapi.fax.plus/v3/accounts/self/contacts", data)
      req.Header = headers

      client := &http.Client{}
      resp, err := client.Do(req)
      // ...
  }
  ```

  ```php PHP theme={null}
  <?php

  require 'vendor/autoload.php';

  $headers = array(
      'Content-Type' => 'application/json',
      'Accept' => 'application/json',
      'Authorization' => 'Bearer {access-token}',
      // The x-fax-clientid header is required only when using the OAuth2 token scheme
      'x-fax-clientid' => '{client ID}',
  );

  $client = new GuzzleHttp\Client();

  $body = array(
      'name' => 'John Doe',
      'company' => 'Acme Corp',
      'numbers' => array('+1234567890'),
      'emails' => array('john@example.com'),
      'address' => '123 Main St',
      'notes' => 'Important client'
  );

  try {
      $response = $client->request('POST','https://restapi.fax.plus/v3/accounts/self/contacts', array(
          'headers' => $headers,
          'json' => $body,
          )
      );
      print_r($response->getBody()->getContents());
   }
   catch (GuzzleHttp\Exception\BadResponseException $e) {
      // handle exception or api errors.
      print_r($e->getMessage());
   }

   // ...
  ```

  ```bash cURL theme={null}
  curl -X POST https://restapi.fax.plus/v3/accounts/self/contacts \
    -H 'Content-Type: application/json' \
    -H 'Accept: application/json'  \
    -H 'Authorization: Bearer {access-token}' \
    -H 'x-fax-clientid: "YOUR_CLIENT_ID"' \
    -d '{
      "name": "John Doe",
      "company": "Acme Corp",
      "numbers": ["+1234567890"],
      "emails": ["john@example.com"],
      "address": "123 Main St",
      "notes": "Important client"
    }'
  ```
</RequestExample>


## OpenAPI

````yaml post /accounts/self/contacts
openapi: 3.0.1
info:
  title: Fax.Plus REST API
  description: >-
    This is the Fax.Plus API v3 developed for third party developers and
    organizations. In order to have a better coding experience with this API,
    let's quickly go through some points:<br /><br /> - This API assumes
    **/accounts** as an entry point with the base url of
    **https://restapi.fax.plus/v3**. <br /><br /> - This API treats all date and
    times sent to it in requests as **UTC**. Also, all dates and times returned
    in responses are in **UTC**<br /><br /> - Once you have an access_token, you
    can easily send a request to the resource server with the base url of
    **https://restapi.fax.plus/v3** to access your permitted resources. As an
    example to get the user's profile info you would send a request to
    **https://restapi.fax.plus/v3/accounts/self** when **Authorization** header
    is set to **Bearer YOUR_ACCESS_TOKEN** and custom header of
    **x-fax-clientid** is set to YOUR_CLIENT_ID
  version: 3.4.0
  contact:
    name: Fax.Plus
    email: info@fax.plus
    url: https://github.com/alohi
servers:
  - url: https://restapi.fax.plus/v3
  - url: /v3
security: []
paths:
  /accounts/self/contacts:
    post:
      tags:
        - Contacts
      summary: Create a contact
      description: 'Create a new contact (Permitted scopes: **fax:all:edit**)'
      operationId: createContact
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContactCreate'
      responses:
        '201':
          $ref: '#/components/responses/Contact'
        '400':
          $ref: '#/components/responses/Error'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '500':
          $ref: '#/components/responses/ServerError'
      security:
        - personal_access_token:
            - fax:all:edit
        - oauth2:
            - all
components:
  schemas:
    ContactCreate:
      type: object
      properties:
        name:
          type: string
          description: Contact name
          example: John Doe
        company:
          type: string
          description: Company name
          example: Acme Corporation
        fax_number:
          type: string
          description: Contact's fax number
          example: '+12025551234'
        email:
          type: string
          description: Contact's email address
          example: john.doe@example.com
        cellphone:
          type: string
          description: Contact's cellphone number
          example: '+12025551235'
        phone:
          type: string
          description: Contact's phone number
          example: '+12025551236'
        address:
          type: string
          description: Contact address
          example: 123 Main St, New York, NY 10001
        notes:
          type: string
          description: Additional notes
          example: Prefers email communication
        groups:
          type: array
          items:
            type: string
          description: List of group IDs
          example:
            - 5f7a8b9c0d1e2f3a4b5c6d7f
        is_telefax:
          type: boolean
          description: Whether this contact has a human fax operator
          example: false
        shared:
          type: boolean
          description: Whether to share contact with corporate members
          example: false
      required:
        - name
    Contact:
      type: object
      properties:
        id:
          type: string
          description: Contact ID
          example: 5f7a8b9c0d1e2f3a4b5c6d7e
        name:
          type: string
          description: Contact name
          example: John Doe
        company:
          type: string
          description: Company name
          example: Acme Corporation
        fax_number:
          type: string
          description: Contact's fax number
          example: '+12025551234'
        groups:
          type: array
          items:
            type: string
          description: List of group IDs
          example:
            - 5f7a8b9c0d1e2f3a4b5c6d7f
            - 5f7a8b9c0d1e2f3a4b5c6d80
        email:
          type: string
          description: Contact's email address
          example: john.doe@example.com
        cellphone:
          type: string
          description: Contact's cellphone number
          example: '+12025551235'
        phone:
          type: string
          description: Contact's phone number
          example: '+12025551236'
        address:
          type: string
          description: Contact address
          example: 123 Main St, Suite 100, New York, NY 10001
        notes:
          type: string
          description: Additional notes
          example: VIP client, prefers email communication
        is_shared:
          type: boolean
          description: Whether contact is shared with corporate members
          example: false
        creation_date:
          type: string
          description: Date contact was created
          example: '2024-01-15T10:30:00Z'
        modification_date:
          type: string
          description: Date contact was last modified
          example: '2024-03-20T14:45:00Z'
    Error:
      properties:
        description:
          type: string
        error:
          type: string
      additionalProperties: false
  responses:
    Contact:
      description: Response containing a single contact object
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Contact'
    Error:
      description: Error object in case there's a problem with given data
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: invalid_user_id
            description: Invalid user id given
    UnauthorizedError:
      description: Error object in case there's a problem with the authorization
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: unauthorized
            description: >-
              The access token provided is expired, revoked, malformed, or
              invalid for other reasons.
    ServerError:
      description: Error object in case there's a server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: internal_server_error
            description: An unexpected error happened, please contact support
  securitySchemes:
    personal_access_token:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Personal Access Token (PAT) is a Bearer token used for secure API calls.
        For direct API calls, the PAT is used in the Authorization header as
        'Bearer {PAT}'. For MCP usage, configure your PAT in your MCP client
        settings (e.g., in your IDE's MCP server configuration) - authentication
        will be handled automatically.
    oauth2:
      type: oauth2
      description: OAuth2 Authorization Grant
      flows:
        authorizationCode:
          authorizationUrl: >-
            https://accounts.fax.plus/login?response_type=code&client_id=YOUR_CLIENT_ID&redirect_uri=http://localhost&scope=all
          tokenUrl: https://accounts.fax.plus/token
          refreshUrl: >-
            https://accounts.fax.plus/token?grant_type=refresh_token&refresh_token=YOUR_REFRESH_TOKEN
          scopes:
            all: >-
              for now when a user grants permission, all grants will be
              permitted

````