---
title: Network Well Definition
slug: network-well-definition
docTags: 
createdAt: 2023-11-14T00:08:08.369Z
---

The Network Well Definition links wells to the network. The **sourceId** must match a sourceId in the [Well](docId\:P-xHbe4jqKJQemay7aOL5) table — records referencing an unknown well are rejected. The unique constraint on network well definitions is **sourceNetworkId + sourceId** (and since sourceId must match a Well sourceId, it is globally unique by proxy). Re-posting the same network and well upserts the existing record.

| **Variable**       | **Data Type**  | **Unit of Measure** | **Is Nullable?** | **Default Value** | **Description**                                                                                                                           |
| ------------------ | -------------- | ------------------- | ---------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| sourceNetworkId    | String         | -                   | No               | -                 | Source ID of the [Network Header](docId\:irXj-Rg5lEh701vW2okjL) the well belongs to                                                       |
| sourceId           | String         | -                   | No               | -                 | Source ID for the well definition. Must match the sourceId of a record in the [Well](docId\:P-xHbe4jqKJQemay7aOL5) table.                 |
| date               | DateTimeOffset | -                   | No               | -                 | Date at which the well becomes part of the network. Datetime offset (with timezone) in ISO 8601 format. Example: 2022-09-27T16:28:37+0000 |
| downstreamSourceId | String         | -                   | No               | -                 | Source ID of the downstream node. Most commonly a [Network Pipe Definition](docId\:NM2btVSv7hAiitak2O9Yw) sourceId.                       |
| upstreamSourceId   | String         | -                   | Yes              | -                 | If there is gas lift injection in the well, this connects the well to the upstream injection network                                      |
| enabled            | Bool           | -                   | No               | -                 | Whether the well should participate in the network (false is the equivalent of a mask in GAP)                                             |

***

# Data Integrity Checks

| **Condition**                                   | **Response**    |
| ----------------------------------------------- | --------------- |
| Any non-nullable field is NULL or empty         | Record Rejected |
| sourceNetworkId does not match a Network Header | Record Rejected |
| sourceId does not exist in the Well table       | Record Rejected |

***

# Common Error Messages

| **API**                   | **Scenario**            | **Error Response**                      |
| ------------------------- | ----------------------- | --------------------------------------- |
| Add / Upsert network well | Unknown sourceNetworkId | network was not found for source id xxx |
| Add / Upsert network well | Unknown well sourceId   | well with sourceId of xxx was not found |
