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

# Müşteri Oluşturma

> Modern ödeme altyapısı için güçlü ve esnek API çözümü

<Note>
  Ödeme işlemlerinizden önce müşteri oluşturarak ödemeleri takip edebilir ve müşteri bilgilerini saklayabilirsiniz. Müşteri oluşturma işlemi, ödeme işlemlerinizin temelini oluşturur.
</Note>

<Warning>
  White label kullanıyorsanız müşteri bilgisi zorunludur.
</Warning>

<br />

İstek:

<CodeGroup>
  ```php PHP theme={null}
  $tahsilat = new TahsilatClient('sk_test_rwwg...');

  $customer = $tahsilat->customers->create([
      'name' => 'John',
      'lastname' => 'Doe',
      'email' => 'example@example.com',
      'phone' => '1234567890',
      'country' => 'TR',
      'city' => 'İstanbul',
      'district' => 'Kadıköy',
      'address' => '123 Main St',
      'zip_code' => '34710',
      'metadata' => [
          'customer_type' => 'premium',
          'special_id' => 123456
      ]
  ]);
  ```

  ```csharp .NET theme={null}
  var tahsilat = new TahsilatClient("sk_test_rwwg...");

  var request = new CustomerCreateRequest
  {
      Name = "John",
      LastName = "Doe",
      Email = "example@example.com",
      Phone = "1234567890",
      Country = "TR",
      City = "İstanbul",
      District = "Kadıköy",
      Address = "123 Main St",
      ZipCode = "34710",
      Metadata = new()
      {
          new Dictionary<string, object>
          {
              ["special_id"] = "123456",
              ["customer_type"] = "premium"
          },
      }
  };

  var response = await tahsilat.Customers.CreateAsync(request);
  ```

  ```curl cURL theme={null}
  curl -L 'https://api.tahsilat.com/v1/customers' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'Accept-Language: tr' \
  -H 'Authorization: Bearer {access_token}' \
  -d 'name=John' \
  -d 'lastname=Doe' \
  -d 'email=example@example.com' \
  -d 'phone=1234567890' \
  -d 'country=TR' \
  -d 'city=İstanbul' \
  -d 'district=Kadıköy' \
  -d 'address=123 Main St' \
  -d 'zip_code=34710' \
  -d 'metadata={"customer_type":"premium", "special_id":123456}'
  ```
</CodeGroup>

<br />

Yanıt:

<CodeGroup>
  ```php PHP theme={null}
  ^ Tahsilat\Resource\Customer {
      "id": 18906378310892
      "merchant_id": 1234567
      "name": "John"
      "lastname": "Doe"
      "name_lastname": "John Doe"
      "phone_code": "+90"
      "phone": "1234567890"
      "email": "example@example.com"
      "country": "TR"
      "country_flag_url": "https://files.tahsilat.com/assets/images/flags/tr.svg"
      "city": "İstanbul"
      "district": "Kadıköy"
      "address": "123 Main St"
      "zip_code": "34710"
      "created_via_payment": false
      "created_at": "2025-06-11T20:27:15+03:00"
      "updated_at": "2025-06-11T20:27:15+03:00"
      "formatted_created_at": "11 Haz, 20:27"
      "metadata": array:2 [
          0 => array:5 [
              "merchant_id" => "1234567"
              "key" => "customer_type"
              "value" => "premium"
              "created_at" => "2025-06-11T20:27:15+03:00"
              "updated_at" => "2025-06-11T20:27:15+03:00"
          ]
          1 => array:5 [
              "merchant_id" => "1234567"
              "key" => "special_id"
              "value" => "123456"
              "created_at" => "2025-06-11T20:27:15+03:00"
              "updated_at" => "2025-06-11T20:27:15+03:00"
          ]
      ]
      "timeline": array:1 [
          0 => array:5 [
              "type" => "created"
              "order" => 1
              "text" => "Müşteri oluşturuldu."
              "date" => "11.06.2025 20:27"
              "icon" => "fa-user-clock"
          ]
      ]
  }
  ```

  ```csharp .NET theme={null}
  {
    "Id": 38933812934740,
    "MerchantId": 1234567,
    "Name": "John",
    "LastName": "Doe",
    "NameLastName": "John Doe",
    "PhoneCode": "+90",
    "Phone": "1234567890",
    "Email": "example@gmail.com",
    "Country": "TR",
    "CountryFlagUrl": "https://files.tahsilat.com/assets/images/flags/tr.svg",
    "City": "İstanbul",
    "District": "Kadıköy",
    "Address": "123 Main St",
    "ZipCode": "34710",
    "CreatedViaPayment": false,
    "CreatedAt": "2025-06-11T20:27:15+03:00",
    "UpdatedAt": "2025-06-11T20:27:15+03:00",
    "FormattedCreatedAt": "4 Mar, 00:34",
    "Metadata": [
      {
        "Key": "customer_type",
        "Value": "premium"
      },
      {
        "Key": "special_id",
        "Value": "123456"
      }
    ],
    "Timeline": [
      {
        "Type": "created",
        "Order": 1,
        "Text": "Müşteri Oluşturuldu.",
        "Date": "04.03.2026 00:34",
        "Icon": "fa-user-clock"
      }
    ]
  }
  ```
</CodeGroup>

<br />

Ödeme Başlatma

<CodeGroup>
  ```php PHP theme={null}
  $tahsilat = new TahsilatClient('sk_test_rwwg...');

  $customer = $tahsilat->customers->create([
      'name' => 'John',
      'lastname' => 'Doe',
      'email' => 'example@example.com',
      'phone' => '1234567890',
      'country' => 'TR',
      'city' => 'İstanbul',
      'district' => 'Kadıköy',
      'address' => '123 Main St',
      'zip_code' => '34710',
      'metadata' => [
          'customer_type' => 'premium',
          'special_id' => 123456
      ]
  ]);

  $payment = $tahsilat->payments->create([
      'customer_id' => $customer->id,
      'currency' => 'TRY',
      'amount' => 1000,
      'product_ids' => ['66659809656479'],
  ]);
  ```

  ```csharp .NET theme={null}
  var tahsilat = new TahsilatClient("sk_test_rwwg...");

  var customerRequest = new CustomerCreateRequest
  {
      Name = "John",
      LastName = "Doe",
      Email = "example@example.com",
      Phone = "1234567890",
      Country = "TR",
      City = "İstanbul",
      District = "Kadıköy",
      Address = "123 Main St",
      ZipCode = "34710",
      Metadata = new()
      {
          new Dictionary<string, object>
          {
              ["special_id"] = "123456",
              ["customer_type"] = "premium"
          },
      }
  };

  var customerResponse = await tahsilat.Customers.CreateAsync(customerRequest);

  var paymentRequest = new PaymentCreateRequest
  {
      Amount = 1000,
      Currency = "TRY",
      CustomerId = customerResponse.Id,
      Metadata = new()
      {
          new Dictionary<string, object>
          {
              ["order_id"] = 123456,
              ["customer_type"] = "premium"
          },
      },
  };

  var paymentResponse = await tahsilat.Payments.CreateAsync(paymentRequest);
  ```
</CodeGroup>

## Zorunlu ve İsteğe Bağlı Parametreler

<ResponseField name="name" type="string" required>
  Müşterinin adı. Bu alan zorunludur ve müşteri oluşturma işlemi için gereklidir.
</ResponseField>

<ResponseField name="lastname" type="string" required>
  Müşterinin soyadı. Bu alan zorunludur ve müşteri oluşturma işlemi için gereklidir.
</ResponseField>

<ResponseField name="email" type="string" required>
  Müşterinin e-posta adresi. Bu alan zorunludur ve müşteri oluşturma işlemi için gereklidir.
</ResponseField>

<ResponseField name="phone" type="string" required>
  Müşterinin telefon numarası. Bu alan zorunludur. Telefon numarası uluslararası formatta olmalıdır.
</ResponseField>

<ResponseField name="country" type="string" required>
  Müşterinin bulunduğu ülke. Bu alan zorunludur ve ISO 3166-1 alpha-2 formatında olmalıdır (örneğin, "TR" Türkiye için).
</ResponseField>

<ResponseField name="city" type="string">
  Müşterinin bulunduğu şehir. Bu alan isteğe bağlıdır, ancak adres bilgilerini tamamlama için önerilir.
</ResponseField>

<ResponseField name="district" type="string">
  Müşterinin bulunduğu ilçe. Bu alan isteğe bağlıdır, ancak adres bilgilerini tamamlama için önerilir. Şehir, ilçe belirtildiğinde bu alan zorunlu hale gelir.
</ResponseField>

<ResponseField name="address" type="string">
  Müşterinin adresi. Bu alan isteğe bağlıdır, ancak iletişim ve fatura işlemleri için önerilir.
</ResponseField>

<ResponseField name="zip_code" type="string">
  Müşterinin posta kodu. Bu alan isteğe bağlıdır, ancak adres bilgilerini tamamlama için önerilir.
</ResponseField>

<ResponseField name="metadata" type="array">
  Müşteri ile ilişkili ek veriler. Bu alan isteğe bağlıdır ve anahtar-değer çiftleri şeklinde veri saklamak için kullanılabilir. Örneğin, müşteri türü, özel ID gibi bilgiler burada tutulabilir.
</ResponseField>

<div className="panels">
  <Panel>
    <CodeGroup>
      ```md Endpoint theme={null}
      POST /v1/customers
      POST /v1/customers/:customer_id
      GET /v1/customers/:customer_id
      GET /v1/customers/search?:sources
      DEL /v1/customers/:customer_id
      ```
    </CodeGroup>

    <br />

    İstek

    <CodeGroup>
      ```php PHP theme={null}
      $tahsilat = new TahsilatClient('sk_test_rwwg...');

      $customer = $tahsilat->customers->create([
          'name' => 'John',
          'lastname' => 'Doe',
          'email' => 'example@example.com',
          'phone' => '1234567890',
      ]);
      ```

      ```csharp .NET theme={null}
      var tahsilat = new TahsilatClient("sk_test_rwwg...");

      var request = new CustomerCreateRequest
      {
          Name = "John",
          LastName = "Doe",
          Email = "example@example.com",
          Phone = "1234567890",
          Country = "TR",
          City = "İstanbul",
          District = "Kadıköy",
          Address = "123 Main St",
          ZipCode = "34710",
          Metadata = new()
          {
              new Dictionary<string, object>
              {
                  ["special_id"] = "123456",
                  ["customer_type"] = "premium"
              },
          }
      };

      var response = await tahsilat.Customers.CreateAsync(request);
      ```

      ```curl cURL theme={null}
      curl -L 'https://api.tahsilat.com/v1/customers' \
      -H 'Content-Type: application/x-www-form-urlencoded' \
      -H 'Accept-Language: tr' \
      -H 'Authorization: Bearer {access_token}' \
      -d 'name=John' \
      -d 'lastname=Doe' \
      -d 'email=example@example.com' \
      -d 'phone=1234567890' \
      ```
    </CodeGroup>

    <br />

    Yanıt

    <CodeGroup>
      ```php PHP theme={null}
      ^ Tahsilat\Resource\Customer {
          "id": 51503395683326
          "merchant_id": 1234567
          "name": "John"
          "lastname": "Doe"
          "name_lastname": "John Doe"
          "phone_code": "+90"
          "phone": "1234567890"
          "email": "example@example.com"
          "country": "tr"
          "city": null
          "district": null
          "address": null
          "zip_code": null
          "created_via_payment": false
          "created_at": "2025-06-11T20:30:33+03:00"
          "updated_at": "2025-06-11T20:30:33+03:00"
          "formatted_created_at": "11 Haz, 20:30"
          "metadata": []
          "timeline": array:1 [
              0 => array:5 [▼
                  "type" => "created"
                  "order" => 1
                  "text" => "Müşteri oluşturuldu."
                  "date" => "11.06.2025 20:30"
                  "icon" => "fa-user-clock"
              ]
          ]
      }
      ```

      ```csharp .NET theme={null}
      {
        "Id": 38933812934740,
        "MerchantId": 1234567,
        "Name": "John",
        "LastName": "Doe",
        "NameLastName": "John Doe",
        "PhoneCode": "+90",
        "Phone": "1234567890",
        "Email": "example@gmail.com",
        "Country": "TR",
        "CountryFlagUrl": "https://files.tahsilat.com/assets/images/flags/tr.svg",
        "City": "İstanbul",
        "District": "Kadıköy",
        "Address": "123 Main St",
        "ZipCode": "34710",
        "CreatedViaPayment": false,
        "CreatedAt": "2025-06-11T20:27:15+03:00",
        "UpdatedAt": "2025-06-11T20:27:15+03:00",
        "FormattedCreatedAt": "4 Mar, 00:34",
        "Metadata": [
          {
            "Key": "customer_type",
            "Value": "premium"
          },
          {
            "Key": "special_id",
            "Value": "123456"
          }
        ],
        "Timeline": [
          {
            "Type": "created",
            "Order": 1,
            "Text": "Müşteri Oluşturuldu.",
            "Date": "04.03.2026 00:34",
            "Icon": "fa-user-clock"
          }
        ]
      }
      ```
    </CodeGroup>
  </Panel>
</div>
