Please read the Data Schema Fundamentals document before using the API. Database CRUD operations are performed via the API and therefore it is important to think of each HTTP REST operation (POST/GET/DELETE) as a SQL transaction (UPSERT/SELECT/DELETE).
WellView® and OpenWells® Source Systems:
The API uses original source system IDs as key fields. For WellView and OpenWells data schema documentation provides guidance as to which table/view and which column/value to use as the source system ID. Guidance is provided for the Well Header, Wellbore and all other Wellbore related data sets
WellView is a registered trademark of Peloton Computer Enterprises Ltd. OpenWells is a registered trademark of Halliburton Landmark.
Visualizing Data:
Data inserted or modified using this tutorial can be visualized using the web portal application(s) at https://<tenant>.app.onxecta.com. The portal contains a Data Quality Reporting tool where you can see what data is in the system, the validity of the data and when the data was last modified.
1 Project Setup
1.1 Project Creation
Create New Project
Open Visual Studio 2022 Community Edition and Create a new C# Console Application
Provide a name for the project e.g., ConsoleApp1
Choose .NET framework version NET 6.0 or higher


1.2 Xecta.Platform.Data.Client
On the project Dependencies tree -> Right Click -> Manage NuGet Packages... Follow the stemps below to find and install the Xecta.Platform.Data.Client from NuGet package manager

On the NuGet Window -> Browse -> Search for Xecta.Platform.DataClient -> Select latest 2.X version.

2. Connect to API
To connect to the API, you will need:
Your PEM File
Your KEY File
Client ID
Client Secret
Open the program.cs - Delete the default Visual Studio "Hello World" code and replace it with the code snippet below
C#
usingXecta.Data.Api.Client;// <-- Reference to Xecta api NamespaceusingXecta.Data.OpenApi.Client.Model;// <-- Reference to Xecta OpenApi DTOsXectaApiClient? _client;// <-- Reference to api client//Section 2. Connect to APItry{string dataServer ="https://data.onxecta.com";// <-- Xecta API serverstring authServer ="https://prod.authenticate.onxecta.com";// <-- Xecta authentication serverstring mTlsPem =@"c:\Demo_Keys\xecta-data-api.pem";// <-- Your mTLS Pem file here string mTlsKey =@"c:\Demo_Keys\xecta-data-api.key";// <-- Your mTLS Key file herestring clientId ="<your id>";// <-- Your Client ID herestring clientSecret ="<your secret>";// <-- Your Client secret here// Create a secure mTls connection to API XectaApi xectaApi =newXectaApi(dataServer,
authServer,
mTlsPem,
mTlsKey);// Authenticate and start client session
_client = xectaApi.Authenticate(clientId,
clientSecret);
Console.WriteLine("Client is connected.");}catch(Exception ex){// Probably an TLS Certificate error or a Client/Secret authentication error// e.g. System.Security.Authentication.AuthenticationException: // Api and Secret key seems to be invalid
Console.WriteLine(ex.ToString());}

3. Well Header Data
The code snippets in section 2 build on the code snippets used in section 2. The snippets assume you have successfully built and ran the code in Section 2. To read more about Well Headers and to see all of the properties.
3.1 UPSERT Well Headers
Put this code directly below the below the Section 2 code snippet
C#
// 3. 3.1 Add a new well to the well header table // Create and UPSERT 2 well headersvar wells =newList<WellInput>();
wells.Add(newWellInput(sourceId:"DB-ID-WELL-001",uwi:"00123456789120",name:"Example Producer Well 1",lat:0,lon:0,group1:"Bakken Operations",group2:"Route A",group3:"Example Well Pad",fluid: WellInput.FluidEnum.OIL,type: WellInput.TypeEnum.PRODUCER,liftType: WellInput.LiftTypeEnum.NATURALFLOW
));
wells.Add(newWellInput(sourceId:"DB-ID-WELL-002",uwi:"00123456789121",name:"Example Producer Well 2",lat:0,lon:0,group1:"Bakken Operations",group2:"Route A",group3:"Example Well Pad",fluid: WellInput.FluidEnum.OIL,type: WellInput.TypeEnum.PRODUCER,liftType: WellInput.LiftTypeEnum.NATURALFLOW
));// UPSERT wellsvar upsertedWells =await client.WellHeaderApi().UpsertWellsAsync(wells);
Console.WriteLine("Added: "+ wells.Count +" wells");foreach(var well in upsertedWells)
Console.WriteLine(well.SourceId +" | "+ well.Name);

3.2 GET Well Headers
C#
// 3. 3.2 Get all wells from well header tabletry{// GET a list of well headers var wellList =await client.WellHeaderApi().GetWellsAsync();
Console.WriteLine("Found: "+ wellList.Count +" wells");foreach(var wellHeader in wellList)
Console.WriteLine(wellHeader.Name);}catch(Exception ex){// Most likely an authentication error
Console.WriteLine(ex.ToString());
Environment.Exit(1);}

3.3 DELETE Well Header
C#
// 3. 3.3 Delete a well from the well header tabletry{// DELETE well headerconststring wellSourceSystemId ="DB-ID-WELL-002";await client.WellHeaderApi().DeleteWellBySourceAsync(wellSourceSystemId);
Console.WriteLine("Deleted well: "+ wellSourceSystemId);}catch(Exception ex){
Console.WriteLine(ex.ToString());
Environment.Exit(1);}

3.4 DELETE Well Headers
The snippet below will delete all wells from the databaseDo not use this snippet unless you have a real-world use case
C#
// 3. 3.4 - Delete all well headersif(_client !=null){//try//{// // Get a list of well headers // var allWells =// await _client.WellHeaderApi().GetWellsAsync();// // Delete each well (deletes the well and all data related to the well)// foreach (Well w in allWells)// {// await _client.WellHeaderApi().DeleteWellAsync(w.SourceId);// Console.WriteLine("Deleted well: " + w.Uwi + " " + w.Name);// }//}//catch (Exception ex)//{// Console.WriteLine(ex.Message);//}}

4. Wellbore
The code snippets below use source Ids from the wells created by the code snippets in Section 3. The snippets assume you have successfully built and ran the code in Section 3. To read more about a Wellbore and to see all of the properties.
A well must exist in the well header table before a wellbore can be added for that well. A well must have at least one wellbore
4.1 UPSERT Wellbore
C#
// 4. 4.1 - Create a wellbore.try{var sourceWellId ="DB-ID-WELL-001";//<-- Required. Well ID/Primary Key from your source databasevar defaultBoreId ="DB-ID-WELL-001-BORE-0";//<-- Required. Main Bore ID/Primary Key from your source databasevar sideTrackBoreId ="DB-ID-WELL-001-SideTrackA";//<-- Secondary bore ID/Primary key // Create 2 well bores for this wellvar wellBores =newList<WellboreInput>();
wellBores.Add(newWellboreInput(sourceWellId: sourceWellId,// <--Required. well source system ID
sourceId: defaultBoreId,// <-- Required. wellbore source system ID
junctionMd:0,// <-- Required. The wellbore starts at surface
name:"Main Bore"// <-- Required. (use "Main Bore" if no name is available)));
wellBores.Add(newWellboreInput(sourceWellId: sourceWellId,// <--Required. well source system ID
sourceId: sideTrackBoreId,// <-- Required. wellbore source system ID
junctionMd:2000,// <-- Side Track bore attaches to main bore at 2000ft
name:"SideTrack A"// <-- Required. Must specify a name for the side track));// UPSERT well bore(s)await client.WellboreApi().UpsertWellboresAsync(wellBores);
Console.WriteLine("Created "+ wellBores.Count +" well bores for well "+ sourceWellId);}catch(Exception ex){// Most likely the Well Source system Id did not exist in well header table
Console.WriteLine(ex.ToString());
Environment.Exit(1);}

4.2 GET Wellbores
C#
// 4. 4.2 - Get wellbore(s)try{conststring sourceWellId ="DB-ID-WELL-001";//<-- Required. Well ID/Primary Key from your source databaseconststring sourceBoreId ="DB-ID-WELL-001-BORE-0";var boresForWell =await client.WellboreApi().GetWellborBySourceAsync(sourceWellId, sourceBoreId);
Console.WriteLine("Found "+ boresForWell.Name +" wellbore for well "+ sourceWellId);}catch(Exception ex){// Most likely the Well Source system Id did not exist in well header table
Console.WriteLine(ex.ToString());
Environment.Exit(1);}

4.3 DELETE Wellbore
C#
// 4. 4.3 - Delete a wellboretry{// DELETE wellboreconststring sourceWellId ="DB-ID-WELL-001";//<-- Required. Well ID/Primary Key from your source databaseconststring sourceBoreId ="DB-ID-WELL-001-SideTrackA";//<-- Required. SourceId of Bore being deletedawait client.WellboreApi().DeleteWellboreBySourceAsync(sourceWellId, sourceBoreId);
Console.WriteLine("Wellbore deleted: "+ sourceBoreId);}catch(Exception ex){// Most likely the wellbore SourceId did not exist
Console.WriteLine(ex.ToString());
Environment.Exit(1);}

5. Wellbore Formation
A wellbore must exist before the formation data for that wellbore can be created
Wellbore Formation Terminology
Wellbore formation represents the rock properties and the fluid properties within the reservoir (formation) where the wellbore is producing the fluids from.
5.1 UPSERT Wellbore Formation
C#
// 5. 5.1 - Create wellbore formation info try{conststring defaultWellId ="DB-ID-WELL-001";conststring defaultBoreId ="DB-ID-WELL-001-BORE-0";//<-- Required. Bore ID/Primary Key from your source databasevar formationProperties =newList<FormationInput>();
formationProperties.Add(newFormationInput(sourceWellId: defaultWellId,sourceWellboreId: defaultBoreId,name: defaultBoreId,allocationFactor:1,compressibilityRock:0.000006,depth:7200,fluidComingledGOR:7200,fluidGravityApi:38,fluidGravityGas:0.78,fluidMolarFracCO2:0.002,fluidMolarFracH2S:0.01,fluidMolarFracN2:0.002,fluidSalinityWater:50000,porosity:0.08,pressureFormationInitialDatum:5200,primaryFluidType: FormationInput.PrimaryFluidTypeEnum.OIL,rsi:800,saturationGasInitial:0.1,saturationOilInitial:0.4,saturationWaterInitial:0.5,temperatureFormationDatum:218,thicknessFormation:180,volumeAcquiferInitial:0));// UPSERT new wellbore formation infoawait client.WellboreFormationApi().UpsertFormationsAsync(formationProperties);
Console.WriteLine("Wellbore Formation Info Updated: "+ defaultBoreId);}catch(Exception ex){// Most likely the wellbore Id did not exist
Console.WriteLine(ex.ToString());
Environment.Exit(1);}

5.2 GET Wellbore Formation
C#
// 5. 5.2 - Get wellbore formation info try{conststring sourceWellId ="DB-ID-WELL-001";//<-- Required. Well ID/Primary Key from your source databaseconststring sourceBoreId ="DB-ID-WELL-001-BORE-0";//<-- Required. Bore ID/Primary Key from your source databasevar formationProperties =await client.WellboreFormationApi().GetFormationsByWellAsync(sourceWellId);if(formationProperties.Count >0)
Console.WriteLine("Found Formation Info for : "+ formationProperties[0].Name);else
Console.WriteLine("No formation Info found for: "+ sourceWellId);}catch(Exception ex){// Most likely the wellbore Id did not exist
Console.WriteLine(ex.ToString());}

5.3 DELETE Wellbore Formation
C#
// 5. 5.3 - Delete wellbore formation info try{conststring sourceWellId ="DB-ID-WELL-001";//<-- Required. Well ID/Primary Key from your source databaseconststring sourceBoreId ="DB-ID-WELL-001-BORE-0";//<-- Required. Bore ID/Primary Key from your source databaseawait client.WellboreFormationApi().DeleteFormationBySourceWellboreAsync(sourceWellId, sourceBoreId);
Console.WriteLine("Deleted Formation Info for : "+ sourceBoreId);}catch(Exception ex){// Most likely the wellbore Id did not exist
Console.WriteLine(ex.ToString());
Environment.Exit(1);}

6. Wellbore Deviation Surveys
A wellbore must exist before survey data points can be created for that wellbore. To read more about a Deviation Survey and to see all of the properties.
6.1 UPSERT Survey
C#
// 6. 6.1 - Add a deviation surveytry{conststring sourceWellId ="DB-ID-WELL-001";//<-- Required. Well ID/Primary Key from your source databaseconststring sourceBoreId ="DB-ID-WELL-001-BORE-0";//<-- Required. Bore ID/Primary Key from your source databasevar surveyPoints =newList<DeviationSurveyInput>();for(var i =0; i <50; i++){
surveyPoints.Add(newDeviationSurveyInput(sourceWellId: sourceWellId,sourceWellboreId: sourceBoreId,sourceId:"DB-ID-WELL-001-BORE-0-SURV-0"+ i,//<-- Unique survey point/station id. Required
azi: i,inc: i,md: i,tvd: i
));}// UPSERT Deviation survey
Console.WriteLine("Upserting the deviation survey for : "+ sourceBoreId +". This may take a few seconds.");await client.DeviationSurveyApi().UpsertDeviationSurveysAsync(surveyPoints);
Console.WriteLine("Survey created for: "+ sourceBoreId);}catch(Exception ex){// Most likely the wellbore Id did not exist
Console.WriteLine(ex.ToString());
Environment.Exit(1);}

6.2 GET Survey
C#
// 6. 6.2 - Get a deviation surveytry{// GET Deviation surveyconststring sourceWellId ="DB-ID-WELL-001";//<-- Required. Well ID/Primary Key from your source databaseconststring sourceBoreId ="DB-ID-WELL-001-BORE-0";//<-- Required. Bore ID/Primary Key from your source databasevar survey =await client.DeviationSurveyApi().GetDeviationSurveyBySourceWellboreAsync(sourceWellId, sourceBoreId);
Console.WriteLine("Found deviation survey for : "+ sourceBoreId +". Found "+ survey.Count +" survey points");}catch(Exception ex){// Most likely the wellbore Id did not exist
Console.WriteLine(ex.ToString());
Environment.Exit(1);}

6.3 DELETE Survey
C#
// 6. 6.3 - Delete a deviation surveytry{conststring sourceWellId ="DB-ID-WELL-001";//<-- Required. Well ID/Primary Key from your source databaseconststring sourceBoreId ="DB-ID-WELL-001-BORE-0";//<-- Required. Bore ID/Primary Key from your source databaseawait client.DeviationSurveyApi().DeleteDeviationSurveysBySourceWellboreAsync(sourceWellId, sourceBoreId);
Console.WriteLine("Survey Deleted for "+ sourceBoreId);}catch(Exception ex){// Most likely the wellbore Id did not exist// If you delete a wellbore
Console.WriteLine(ex.ToString());
Environment.Exit(1);}

7 Wellbore Casing
A wellbore must exist before the casing information can be created for that wellbore. To read more about a casing and to see all of the properties.
7.1 UPSERT Casing
C#
// 7. 7.1 - Add casing to the wellboretry{conststring sourceWellId ="DB-ID-WELL-001";//<-- Required. Well ID/Primary Key from your source databaseconststring sourceBoreId ="DB-ID-WELL-001-BORE-0";//<-- Required. Bore ID/Primary Key from your source databasevar wellBoreCasing =newList<CasingInput>();for(var i =0; i <10; i++){
wellBoreCasing.Add(newCasingInput(sourceWellId: sourceWellId,//<-- Required
sourceWellboreId: sourceBoreId,//<-- Required
sourceId:"DB-ID-WELL-001-BORE-0-CAS-"+ i,//<-- Required. Must be unique
topMd: i,//<-- Required
bottomMd: i +1,//<-- Required
od:5,// //<-- RequiredOuter diameter of the casing
id:3,// //<-- RequiredInner diameter of the casing
roughness: i,//<-- Required. Friction. Use 0 if not available
runDate: DateTime.Today //Installation date));}// UPSERT Casing
Console.WriteLine("Upserting the wellbore casing for: "+ sourceBoreId +". This may take a few seconds.");await client.WellboreCasingApi().UpsertCasingAsync(wellBoreCasing);
Console.WriteLine("Casing created for: "+ sourceBoreId);}catch(Exception ex){// Most likely the wellbore Id did not exist
Console.WriteLine(ex.ToString());
Environment.Exit(1);}

7.2 GET Casing
C#
// 7. 7.2 - Get casing for the wellboretry{// GET Casingconststring sourceWellId ="DB-ID-WELL-001";//<-- Required. Well ID/Primary Key from your source databaseconststring sourceBoreId ="DB-ID-WELL-001-BORE-0";//<-- Required. Bore ID/Primary Key from your source databasevar wellboreCasing =await client.WellboreCasingApi().GetCasingBySourceWellboreAsync(sourceWellId, sourceBoreId);
Console.WriteLine("Found casing for : "+ sourceBoreId +". Found "+ wellboreCasing.Count +" Records");}catch(Exception ex){// Most likely the wellbore Id did not exist
Console.WriteLine(ex.ToString());
Environment.Exit(1);}

7.3 DELETE Casing
C#
// 7. 7.3 - delete casing for the wellboretry{// DELETE Casingconststring sourceWellId ="DB-ID-WELL-001";//<-- Required. Well ID/Primary Key from your source databaseconststring sourceBoreId ="DB-ID-WELL-001-BORE-0";//<-- Required. Bore ID/Primary Key from your source databaseawait client!.WellboreCasingApi().DeleteCasingBySourceWellboreAsync(sourceWellId, sourceBoreId);
Console.WriteLine("Deleted casing for : "+ sourceBoreId);}catch(Exception ex){// Most likely the wellbore Id did not exist
Console.WriteLine(ex.ToString());
Environment.Exit(1);}

8. Wellbore Tubing
A wellbore must exist before the tubing information can be created for that wellbore. To read more about tubing and to see all of the properties.
8.1. UPSERT Tubing
C#
// 8. 8.1 - Add tubing to the wellboretry{conststring sourceWellId ="DB-ID-WELL-001";//<-- Required. Well ID/Primary Key from your source databaseconststring sourceBoreId ="DB-ID-WELL-001-BORE-0";//<-- Required. Bore ID/Primary Key from your source databasevar wellboreTubing =newList<TubingInput>();for(var i =0; i <10; i++){
wellboreTubing.Add(newTubingInput(sourceWellId: sourceWellId,//<-- Required
sourceWellboreId: sourceBoreId,//<-- Required
sourceId:"DB-ID-WELL-001-BORE-0-TUB-"+ i,//<-- Required. Must be unique for each object
topMd: i,//<-- Required
bottomMd: i +1,//<-- Required
od:4,// //<-- Required. Outer diameter of the tubing
id:2,// //<-- Required. Inner diameter of the tubing
roughness: i,//<-- Required. Friction. Use 0 if not available
runDate: DateTime.Today //Installation date));}// UPSERT Tubing
Console.WriteLine("Upserting the wellbore tubing for: "+ sourceBoreId +". This may take a few seconds.");await client.WellboreTubingApi().UpsertTubingAsync(wellboreTubing);
Console.WriteLine("Tubing created for: "+ sourceBoreId);}catch(Exception ex){// Most likely the wellbore Id did not exist
Console.WriteLine(ex.ToString());
Environment.Exit(1);}

8.2 GET Tubing
C#
// 8. 8.2 - Get tubing for the wellboretry{// GET Tubingconststring sourceWellId ="DB-ID-WELL-001";//<-- Required. Well ID/Primary Key from your source databaseconststring sourceBoreId ="DB-ID-WELL-001-BORE-0";//<-- Required. Bore ID/Primary Key from your source databasevar wellboreTubing =await client.WellboreTubingApi().GetTubingForSourceWellboreAsync(sourceWellId, sourceBoreId);
Console.WriteLine("Found tubing for : "+ sourceBoreId +". Found "+ wellboreTubing.Count +" Records");}catch(Exception ex){// Most likely the wellbore Id did not exist
Console.WriteLine(ex.ToString());}

8.3 DELETE Tubing
C#
// 8. 8.3 - delete tubing for the wellboretry{// DELETE Tubingconststring sourceWellId ="DB-ID-WELL-001";//<-- Required. Well ID/Primary Key from your source databaseconststring sourceBoreId ="DB-ID-WELL-001-BORE-0";//<-- Required. Bore ID/Primary Key from your source databaseawait client.WellboreTubingApi().DeleteTubingBySourceWellboreAsync(sourceWellId, sourceBoreId);
Console.WriteLine("Deleted tubing for : "+ sourceBoreId);}catch(Exception ex){// Most likely the wellbore Id did not exist
Console.WriteLine(ex.ToString());
Environment.Exit(1);}

9 Daily Production Records
To read more about daily production records and to see all of the properties.
The daily production is related to the well. Not the wellbore. The well UWI property from the well header is used as the primary key for daily production records
See Section 3 for well header API details
9.1 UPSERT Production Record (single record)
C#
// 9. 9.1 -> Insert production recordif(_client !=null){try{DailyProductionInput dailyProductionInput =newDailyProductionInput(){
Uwi ="00123456789120",//<-- Required. Must exist in well header table
Date = DateTime.Today,// <-- Required.
OilRate =100,// <-- Required.
GasRate =500,// <-- Required.
WaterRate =50,// <-- Required.
Choke =32,// <-- Required. (use 0 if not available)
TubingPressure =150,// <-- Required.
CasingPressure =75,// <-- Required.
DowntimeHours =12,// <-- Optional.(use 0 if not available)
DowntimeCode ="POWER-LOSS-PAD",//<-- Optional (use empty string or null if not avaialable)//Other optional lift related inputs are available e.g. EspFrequency};// UPSERT 1 Daily production recordawait _client.ProductionApi().UpsertDailyAsync(newList<DailyProductionInput>(){ dailyProductionInput });
Console.WriteLine("Daily Production Record Created: "+ dailyProductionInput.Uwi);}catch(Exception ex){// Most likely a required field is missing
Console.WriteLine(ex.Message);}}

9.2 UPSERT Production Records (multiple records)
C#
// 9. 9.2 - Insert production historyif(_client !=null){try{// Create 365 daily production recordsList<DailyProductionInput> productionHistory =newList<DailyProductionInput>();var random =newRandom();var uwi ="00123456789120";// <-- Use Well UWI. Do not use SourceIdfor(int i =365; i >=1; i--){
productionHistory.Add(newDailyProductionInput(){
Uwi = uwi,
Date = DateTime.Today.AddDays(-i),// <-- Required.
OilRate =100+ random.Next(50),// <-- Required.
GasRate =500+ random.Next(100),// <-- Required.
WaterRate =50+ random.Next(10),// <-- Required.
Choke =32+ random.Next(5),// <-- Required. Use 0 if not available
TubingPressure =150+ random.Next(30),// <-- Required.
CasingPressure =75+ random.Next(10),// <-- Required});}// UPSERT 365 daily production recordsawait _client.ProductionApi().UpsertDailyAsync(productionHistory);
Console.WriteLine("Production History Inserted for well 00123456789120");}catch(Exception ex){// Most likely a required field is missing//Error calling UpsertDaily: {\"status\":\"BAD_REQUEST\",\"message\":\//"Data integrity violation occurred,//check input arguments\",\"timestamp\":\"2022-10-10T20:59:33.125718\",\"errors\"://[\"Well with uwi 00123456789120 was not found in current schema\"]}"
Console.WriteLine(ex.Message);}}

9.3 GET Production History
Get Latest Production:

To get the most recent production record you have to get the history and then use the latest record. At the time of writing there is not an end point for Get Latest record.
C#
// 9. 9.3 - Get Daily Production if(_client !=null){try{// GET production historyvar uwi ="00123456789120";var productionHistory =await _client.ProductionApi().GetDailyAsync(
uwi,//<-- Use Well UWI.Do not use SourceId
DateTime.MinValue,// <-- History start
DateTime.Today,// <-- History endnull,5000);// <-- Page Size 5000 (limits query to fist 5000 records)
Console.WriteLine("Found "+ productionHistory.Count()+" Daily Production Records for well: "+ uwi);}catch(Exception ex){// Most likely the well UWI did not exist in well header table
Console.WriteLine(ex.Message);}}

9.4 DELETE Production Record (single record)
C#
// 9. 9.4 - Delete production recordif(_client !=null){try{//DELETE single production recordvar uwi ="00123456789120";var numRecordsDeleted =await _client.ProductionApi().DeleteDailyAsync(uwi,
DateTime.Today.AddDays(-1),// <-- Yesterday
DateTime.Today.AddDays(-1));
Console.WriteLine("Production Record Deleted. Well:"+ uwi
+" Deleted Record Count:"+ numRecordsDeleted);}catch(Exception ex){// Most likely the UWI did not exist in well header table
Console.WriteLine(ex.Message);}}

9.5 DELETE Production History (multiple records)
C#
// 9. 9.6 - Delete production historyif(_client !=null){try{// DELETE range of recordsvar uwi ="00123456789120";var numRecordsDeleted =await _client.ProductionApi().DeleteDailyAsync(uwi,
DateTime.MinValue,// <-- Start
DateTime.Today.AddDays(-1));// <-- End;
Console.WriteLine("Production Record Deleted. Well:"+ uwi
+" Deleted Record Count:"+ numRecordsDeleted);}catch(Exception ex){// Most likely the UWI did not exist in well header table
Console.WriteLine(ex.Message);}}

10. Import Data from Excel
The snippet below can run standalone without the other snippets above. The code reads a standard excel template and pushes the data from the excel template to the server. An example MS Excel template file called Excel-Import-Template.xlsx can be found in the Code Samples section.
C#
// The following uses the Xecta.Data.Api.Client.Utils.ExcelReader// The Excel file must be in a specified format// To get a copy of the Excel file go to Code Samples and download Excel-Import-Template.xlsxusingSystem.Text.Json;usingXecta.Data.Api.Client.Utils;// <-- Reference to Xecta API Utils// 1) Read Excel File and push content to API Servertry{string dataServer ="https://data.onxecta.com";// <-- Xecta API serverstring authServer ="https://prod.authenticate.onxecta.com";// <-- Xecta authentication serverstring mTlsPem =@"c:\Demo_Keys\xecta-data-api.pem";// <-- Your mTLS Pem file here string mTlsKey =@"c:\Demo_Keys\xecta-data-api.key";// <-- Your mTLS Key file herestring clientId ="<your id>";// <-- Your Client ID herestring clientSecret ="<your secret>";// <-- Your Client secret herestring filePath =@"c:\Your-Excel-Import-File.xlsx";// <-- full path to xlsx file eg. @"c:\temp\test.xlsx"// Create a new Excel Readervar excelReader =newExcelReader();// Read XLSX file from local diskbyte[] file = File.ReadAllBytes(filePath);MemoryStream ms =newMemoryStream(file);// Load and Validate file (this step takes a few minutes for large files)bool isValid = excelReader.ValidateInputData(ms);if(isValid){// Connect to API server
excelReader.ConnectToServer(dataServer,
authServer,
mTlsPem,
mTlsKey
clientId
clientSecret);// Push the validated file content to the server // (this step will take between 1-30 mins depending on number of wells)await excelReader.Push(newCancellationToken());// Print result log to screenforeach(var item in excelReader.TransactionalLogs)
Console.WriteLine(item.Name +": "+ item.Message);}}catch(Exception ex){// Most likely mTLS certificate missing error // or a client/secret authentication error// or an XLSX file parsing error
Console.WriteLine(ex.ToString());
Console.ReadLine();return;}