# ADD CUSTOMER

POST https://api.gwapialoha.co/api/agents/[AGENT_ID]/customers/add
Content-Type: application/json

Registers a new customer under the specified agent account.

**Method:** `POST`  
**URL:** `{{ENDPOINT}}/{{AGENT_ID}}/customers/add`

### Parameters

| Variable | Description |
| --- | --- |
| `{{ENDPOINT}}` | Base URL of the API server |
| `{{AGENT_ID}}` | Unique identifier of the agent managing the customer |

### Request Body

Send the customer details (e.g., name, phone number, or other identifying information) as a JSON payload in the request body.

### Authentication

Requires an API key passed via the `x-api-key` request header using the `{{API_KEY}}` environment variable.

### Notes

- This endpoint creates a new customer record linked to the agent identified by `{{AGENT_ID}}`.
    
- Ensure the customer does not already exist before calling this endpoint to avoid duplicate records.

Reference: https://docs.gwapialoha.co/web-api/add-customer

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: collection
  version: 1.0.0
paths:
  /[AGENT_ID]/customers/add:
    post:
      operationId: add-customer
      summary: ADD CUSTOMER
      description: >-
        Registers a new customer under the specified agent account.


        **Method:** `POST`  

        **URL:** `{{ENDPOINT}}/{{AGENT_ID}}/customers/add`


        ### Parameters


        | Variable | Description |

        | --- | --- |

        | `{{ENDPOINT}}` | Base URL of the API server |

        | `{{AGENT_ID}}` | Unique identifier of the agent managing the customer
        |


        ### Request Body


        Send the customer details (e.g., name, phone number, or other
        identifying information) as a JSON payload in the request body.


        ### Authentication


        Requires an API key passed via the `x-api-key` request header using the
        `{{API_KEY}}` environment variable.


        ### Notes


        - This endpoint creates a new customer record linked to the agent
        identified by `{{AGENT_ID}}`.
            
        - Ensure the customer does not already exist before calling this
        endpoint to avoid duplicate records.
      tags:
        - ''
      parameters:
        - name: x-api-key
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ADD CUSTOMER_Response_200'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                chain:
                  type: string
                email:
                  type: string
                  format: email
                phone:
                  type: string
                username:
                  type: string
              required:
                - name
                - chain
                - email
                - phone
                - username
servers:
  - url: https://api.gwapialoha.co/api/agents
components:
  schemas:
    ADD CUSTOMER_Response_200:
      type: object
      properties: {}
      description: Empty response body
      title: ADD CUSTOMER_Response_200
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

```

## SDK Code Examples

```python
import requests

url = "https://api.gwapialoha.co/api/agents/[AGENT_ID]/customers/add"

payload = {
    "name": "Demo Customer",
    "chain": "tron",
    "email": "demo@email.com",
    "phone": "0809991234",
    "username": "0809991234"
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.gwapialoha.co/api/agents/[AGENT_ID]/customers/add';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"name":"Demo Customer","chain":"tron","email":"demo@email.com","phone":"0809991234","username":"0809991234"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.gwapialoha.co/api/agents/[AGENT_ID]/customers/add"

	payload := strings.NewReader("{\n  \"name\": \"Demo Customer\",\n  \"chain\": \"tron\",\n  \"email\": \"demo@email.com\",\n  \"phone\": \"0809991234\",\n  \"username\": \"0809991234\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.gwapialoha.co/api/agents/[AGENT_ID]/customers/add")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"Demo Customer\",\n  \"chain\": \"tron\",\n  \"email\": \"demo@email.com\",\n  \"phone\": \"0809991234\",\n  \"username\": \"0809991234\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.gwapialoha.co/api/agents/[AGENT_ID]/customers/add")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Demo Customer\",\n  \"chain\": \"tron\",\n  \"email\": \"demo@email.com\",\n  \"phone\": \"0809991234\",\n  \"username\": \"0809991234\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.gwapialoha.co/api/agents/[AGENT_ID]/customers/add', [
  'body' => '{
  "name": "Demo Customer",
  "chain": "tron",
  "email": "demo@email.com",
  "phone": "0809991234",
  "username": "0809991234"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.gwapialoha.co/api/agents/[AGENT_ID]/customers/add");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Demo Customer\",\n  \"chain\": \"tron\",\n  \"email\": \"demo@email.com\",\n  \"phone\": \"0809991234\",\n  \"username\": \"0809991234\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "Demo Customer",
  "chain": "tron",
  "email": "demo@email.com",
  "phone": "0809991234",
  "username": "0809991234"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.gwapialoha.co/api/agents/[AGENT_ID]/customers/add")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```