# Create Contact Property

> POST /contact-properties — define a custom property for your contacts.

`POST /contact-properties`

Creates a custom property for your contacts. A property defines a typed, named field (with an optional fallback) that you can then set per-contact and reference in templates and segments.

**Body parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `key` | string | Yes | The property key. Max length is `50` characters. Only alphanumeric characters and underscores are allowed. Also accepted as `name` (alias). |
| `type` | string | No | The property type. Possible values: `string` or `number`. Defaults to `string` when omitted. |
| `fallback_value` | string | number | No | The default value to use when the property is not set for a contact. Must match the type specified in the `type` field. |

**Node.js**

```js
import { SendPing } from 'sendping';

const mb = new SendPing('mb_xxxxxxxxx');

const { data, error } = await mb.contactProperties.create({
  "key": "company_name",
  "type": "string",
  "fallback_value": "Acme Corp"
});
console.log({ data, error });
```

**Ruby**

```ruby
require "sendping"

SendPing.api_key = "mb_xxxxxxxxx"

SendPing::ContactProperties.create({
  "key": "company_name",
  "type": "string",
  "fallback_value": "Acme Corp"
})
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

use SendPing\SendPing;

$sendping = SendPing::client('mb_xxxxxxxxx');

$sendping->contactProperties->create([
  'key' => "company_name",
  'type' => "string",
  'fallback_value' => "Acme Corp"
]);
```

**Python**

```python
import sendping

sendping.api_key = "mb_xxxxxxxxx"

sendping.ContactProperties.create({
  "key": "company_name",
  "type": "string",
  "fallback_value": "Acme Corp"
})
```

**Go**

```go
import "github.com/shekhu10/sendping-sdks/sendping-go"

client := sendping.NewClient("mb_xxxxxxxxx")

property, err := client.ContactProperties.Create(&sendping.CreateContactPropertyRequest{
    Key:           "company_name",
    Type:          "string",
    FallbackValue: "Acme Corp",
})
```

**Rust**

```rust
use sendping::{ContactPropertyType, CreateContactPropertyOptions, SendPing};

let mb = SendPing::new("mb_xxxxxxxxx");

let params = CreateContactPropertyOptions::new(
    "company_name",
    ContactPropertyType::String,
)
.with_fallback_value(serde_json::json!("Acme Corp"));
let _property = mb.contact_properties.create(params).await?;
```

**Java**

```java
import co.sendping.SendPing;
import co.sendping.SendPingResponse;
import co.sendping.requests.CreateContactPropertyRequest;

SendPing sendping = new SendPing("mb_xxxxxxxxx");

CreateContactPropertyRequest request = CreateContactPropertyRequest.builder()
        .key("company_name")
        .type("string")
        .fallbackValue("Acme Corp")
        .build();

SendPingResponse response = sendping.contactProperties().create(request);
```

**.NET**

```csharp
using SendPing;

ISendPing sendping = SendPingClient.Create("mb_xxxxxxxxx");

var resp = await sendping.ContactPropertyCreateAsync(new ContactPropertyCreateOptions
{
    Key = "company_name",
    Type = "string",
    FallbackValue = "Acme Corp",
});
```

**cURL**

```bash
curl -X POST 'https://www.sendping.co/api/contact-properties' \
  -H 'Authorization: Bearer mb_xxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
  "key": "company_name",
  "type": "string",
  "fallback_value": "Acme Corp"
}'
```

**CLI**

```bash
sendping contact-properties create \
  --key 'company_name' \
  --type 'string' \
  --fallback-value 'Acme Corp'
```

### Response

```json
{
  "object": "contact_property",
  "id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e"
}
```
