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

# NSWebhook

> nWebhook definitions. Webhooks broadcast events from NetServer to remote servers.

nWebhook definitions. Webhooks broadcast events from NetServer to remote servers.

## Constructors

### NSWebhook()

```crmscript theme={null}
NSWebhook
```

Initializes a new instance of the NSWebhook class.

## Methods

## GetErrorsEmail()

Email address to send error message to when this webhook state changes to too-many errors.

```crmscript theme={null}
String[] GetErrorsEmail()
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String)\[] - The email address error messages are sent to when this webhook state changes to too-many errors.

<Note>
  Only one email address.
</Note>

**Example:**

```crmscript theme={null}
NSWebhook webhook;
String emailAddress = webhook.GetErrorsEmail();
```

## GetEvents()

```crmscript theme={null}
String[] GetEvents()
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String)\[] - Array of event names that trigger this webhook \['contact.created', 'sale.changed']

**Example:**

```crmscript theme={null}
NSWebhook thing;
String[] events = thing.GetEvents();
```

## GetHeaders()

```crmscript theme={null}
Map GetHeaders()
```

**Returns:** [CRMScript.Native.Map](CRMScript.Native.Map) - Custom HTTP Headers to add to webhook requests.

**Example:**

```crmscript theme={null}
NSWebhook thing;
Map headers = thing.GetHeaders();
```

## GetName()

```crmscript theme={null}
String GetName()
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - Name to identify this webhook. Does not have to be unique.

**Example:**

```crmscript theme={null}
NSWebhook thing;
String name = thing.GetName();
```

## GetProperties()

```crmscript theme={null}
StringObjectDictionary GetProperties()
```

**Returns:** [CRMScript.Native.StringObjectDictionary](CRMScript.Native.StringObjectDictionary) - Custom values to inject into JSON body of webhook call.

**Example:**

```crmscript theme={null}
NSWebhook thing;
StringObjectDictionary properties = thing.GetProperties();
```

## GetRegistered()

```crmscript theme={null}
DateTime GetRegistered()
```

**Returns:** [CRMScript.Global.DateTime](CRMScript.Global.DateTime) - Registered when.

**Example:**

```crmscript theme={null}
NSWebhook thing;
DateTime registered = thing.GetRegistered();
```

## GetRegisteredAssociate()

```crmscript theme={null}
NSAssociate GetRegisteredAssociate()
```

**Returns:** [CRMScript.NetServer.NSAssociate](CRMScript.NetServer.NSAssociate) - The user that created the webhook.

**Example:**

```crmscript theme={null}
NSWebhook thing;
NSAssociate registeredAssociate = thing.GetRegisteredAssociate();
```

## GetSecret()

```crmscript theme={null}
String GetSecret()
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - Shared secret key used for generating SHA256 HMAC signature, so that receiver can verify that call came from this server.

**Example:**

```crmscript theme={null}
NSWebhook thing;
String secret = thing.GetSecret();
```

## GetState()

```crmscript theme={null}
Integer GetState()
```

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - Webhook status, should we post events to the URL? See \<xref href="CRMScript.NetServer.WebhookState" data-throw-if-not-resolved="false">\</xref>.

**Example:**

```crmscript theme={null}
NSWebhook thing;
Integer state = thing.GetState();
```

## GetTargetUrl()

```crmscript theme={null}
String GetTargetUrl()
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - Destination to POST event info to. URL for webhooks. ID for CRM scripts.

**Example:**

```crmscript theme={null}
NSWebhook thing;
String targetUrl = thing.GetTargetUrl();
```

## GetType()

```crmscript theme={null}
String GetType()
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - Name of plugin that handles this webhook. 'webhook' for webhooks, which are handled by the system plugin.

**Example:**

```crmscript theme={null}
NSWebhook thing;
String type = thing.GetType();
```

## GetUpdated()

```crmscript theme={null}
DateTime GetUpdated()
```

**Returns:** [CRMScript.Global.DateTime](CRMScript.Global.DateTime) - Last updated when.

**Example:**

```crmscript theme={null}
NSWebhook thing;
DateTime updated = thing.GetUpdated();
```

## GetUpdatedAssociate()

```crmscript theme={null}
NSAssociate GetUpdatedAssociate()
```

**Returns:** [CRMScript.NetServer.NSAssociate](CRMScript.NetServer.NSAssociate) - The user that last updated the webhook.

**Example:**

```crmscript theme={null}
NSWebhook thing;
NSAssociate updatedAssociate = thing.GetUpdatedAssociate();
```

## GetWebhookId()

```crmscript theme={null}
Integer GetWebhookId()
```

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - Primary Key. Unique id for this webhook.

**Example:**

```crmscript theme={null}
NSWebhook thing;
Integer webhookId = thing.GetWebhookId();
```

## SetErrorsEmail(String)

Email address to send error message to when this webhook state changes to too-many errors.

```crmscript theme={null}
Void SetErrorsEmail(String emailAddress)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

<Note>
  Only one email address.
</Note>

**Example:**

```crmscript theme={null}
NSWebhook webhook;
webhook.SetErrorsEmail('your@email.com');
```

## SetEvents(String\[])

```crmscript theme={null}
Void SetEvents(String[] events)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSWebhook thing;
String[] events;
thing.SetEvents(events);
```

## SetHeaders(Map)

```crmscript theme={null}
Void SetHeaders(Map headers)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSWebhook thing;
Map headers;
thing.SetHeaders(headers);
```

## SetName(String)

```crmscript theme={null}
Void SetName(String name)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSWebhook thing;
String name;
thing.SetName(name);
```

## SetProperties(StringObjectDictionary)

```crmscript theme={null}
Void SetProperties(StringObjectDictionary properties)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSWebhook thing;
StringObjectDictionary properties;
properties.insertInteger("foobar", 42);
thing.SetProperties(properties);
```

## SetRegistered(DateTime)

```crmscript theme={null}
Void SetRegistered(DateTime registered)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSWebhook thing;
DateTime registered;
thing.SetRegistered(registered);
```

## SetRegisteredAssociate(NSAssociate)

```crmscript theme={null}
Void SetRegisteredAssociate(NSAssociate registeredAssociate)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSWebhook thing;
NSAssociate registeredAssociate;
thing.SetRegisteredAssociate(registeredAssociate);
```

## SetSecret(String)

```crmscript theme={null}
Void SetSecret(String secret)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSWebhook thing;
String secret;
thing.SetSecret(secret);
```

## SetState(Integer)

```crmscript theme={null}
Void SetState(Integer state)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSWebhook thing;
Integer state;
thing.SetState(state);
```

## SetTargetUrl(String)

```crmscript theme={null}
Void SetTargetUrl(String targetUrl)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSWebhook thing;
String targetUrl;
thing.SetTargetUrl(targetUrl);
```

## SetType(String)

```crmscript theme={null}
Void SetType(String type)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSWebhook thing;
String type;
thing.SetType(type);
```

## SetUpdated(DateTime)

```crmscript theme={null}
Void SetUpdated(DateTime updated)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSWebhook thing;
DateTime updated;
thing.SetUpdated(updated);
```

## SetUpdatedAssociate(NSAssociate)

```crmscript theme={null}
Void SetUpdatedAssociate(NSAssociate updatedAssociate)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSWebhook thing;
NSAssociate updatedAssociate;
thing.SetUpdatedAssociate(updatedAssociate);
```

## SetWebhookId(Integer)

```crmscript theme={null}
Void SetWebhookId(Integer webhookId)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSWebhook thing;
Integer webhookId;
thing.SetWebhookId(webhookId);
```


## Related topics

- [NSWebhookAgent](/en/automation/crmscript/reference/CRMScript.NetServer.NSWebhookAgent.md)
- [CRMScript webhooks event handlers](/en/automation/webhook/dev/crmscript-handlers.md)
- [NSWebhookResult](/en/automation/crmscript/reference/CRMScript.NetServer.NSWebhookResult.md)
- [Webhook](/en/api/archive-providers/reference/webhook.md)
- [Webhooks](/en/automation/webhook/index.md)
- [Webhooks panel](/en/automation/webhook/admin/index.md)
