# nodes

node_type: n8n-nodes-base.Salesforce
name: Salesforce
display_name: Salesforce
description: Consume Salesforce API
category: Other
code_hash: 6f246b98c15db36cd6ecfb303d5edf8861482d616bc7a416a74aa341105120c3
documentation_url: https://docs.n8n.io/integrations/builtin/credentials/salesforce
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
extracted_at: 2025-06-08 08:05:28
updated_at: 2025-06-08 08:05:28
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.Salesforce = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const AccountDescription_1 = require("./AccountDescription");
  const AttachmentDescription_1 = require("./AttachmentDescription");
  const CaseDescription_1 = require("./CaseDescription");
  const ContactDescription_1 = require("./ContactDescription");
  const CustomObjectDescription_1 = require("./CustomObjectDescription");
  const FlowDescription_1 = require("./FlowDescription");
  const GenericFunctions_1 = require("./GenericFunctions");
  const LeadDescription_1 = require("./LeadDescription");
  const OpportunityDescription_1 = require("./OpportunityDescription");
  const SearchDescription_1 = require("./SearchDescription");
  const TaskDescription_1 = require("./TaskDescription");
  const UserDescription_1 = require("./UserDescription");
  const DocumentDescription_1 = require("./DocumentDescription");
  class Salesforce {
      constructor() {
          this.description = {
              displayName: 'Salesforce',
              name: 'salesforce',
              icon: 'file:salesforce.svg',
              group: ['output'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
              description: 'Consume Salesforce API',
              defaults: {
                  name: 'Salesforce',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'salesforceOAuth2Api',
                      required: true,
                      displayOptions: {
                          show: {
                              authentication: ['oAuth2'],
                          },
                      },
                  },
                  {
                      name: 'salesforceJwtApi',
                      required: true,
                      displayOptions: {
                          show: {
                              authentication: ['jwt'],
                          },
                      },
                  },
              ],
              properties: [
                  {
                      displayName: 'Authentication',
                      name: 'authentication',
                      type: 'options',
                      options: [
                          {
                              name: 'OAuth2',
                              value: 'oAuth2',
                          },
                          {
                              name: 'OAuth2 JWT',
                              value: 'jwt',
                          },
                      ],
                      default: 'oAuth2',
                      description: 'OAuth Authorization Flow',
                  },
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Account',
                              value: 'account',
                              description: 'Represents an individual account, which is an organization or person involved with your business (such as customers, competitors, and partners)',
                          },
                          {
                              name: 'Attachment',
                              value: 'attachment',
                              description: 'Represents a file that a has uploaded and attached to a parent object',
                          },
                          {
                              name: 'Case',
                              value: 'case',
                              description: 'Represents a case, which is a customer issue or problem',
                          },
                          {
                              name: 'Contact',
                              value: 'contact',
                              description: 'Represents a contact, which is an individual associated with an account',
                          },
                          {
                              name: 'Custom Object',
                              value: 'customObject',
                              description: 'Represents a custom object',
                          },
                          {
                              name: 'Document',
                              value: 'document',
                              description: 'Represents a document',
                          },
                          {
                              name: 'Flow',
                              value: 'flow',
                              description: 'Represents an autolaunched flow',
                          },
                          {
                              name: 'Lead',
                              value: 'lead',
                              description: 'Represents a prospect or potential',
                          },
                          {
                              name: 'Opportunity',
                              value: 'opportunity',
                              description: 'Represents an opportunity, which is a sale or pending deal',
                          },
                          {
                              name: 'Search',
                              value: 'search',
                              description: 'Search records',
                          },
                          {
                              name: 'Task',
                              value: 'task',
                              description: 'Represents a business activity such as making a phone call or other to-do items. In the user interface, and records are collectively referred to as activities.',
                          },
                          {
                              name: 'User',
                              value: 'user',
                              description: 'Represents a person, which is one user in system',
                          },
                      ],
                      default: 'lead',
                  },
                  ...LeadDescription_1.leadOperations,
                  ...LeadDescription_1.leadFields,
                  ...ContactDescription_1.contactOperations,
                  ...ContactDescription_1.contactFields,
                  ...CustomObjectDescription_1.customObjectOperations,
                  ...CustomObjectDescription_1.customObjectFields,
                  ...DocumentDescription_1.documentOperations,
                  ...DocumentDescription_1.documentFields,
                  ...OpportunityDescription_1.opportunityOperations,
                  ...OpportunityDescription_1.opportunityFields,
                  ...AccountDescription_1.accountOperations,
                  ...AccountDescription_1.accountFields,
                  ...SearchDescription_1.searchOperations,
                  ...SearchDescription_1.searchFields,
                  ...CaseDescription_1.caseOperations,
                  ...CaseDescription_1.caseFields,
                  ...TaskDescription_1.taskOperations,
                  ...TaskDescription_1.taskFields,
                  ...AttachmentDescription_1.attachmentOperations,
                  ...AttachmentDescription_1.attachmentFields,
                  ...UserDescription_1.userOperations,
                  ...UserDescription_1.userFields,
                  ...FlowDescription_1.flowOperations,
                  ...FlowDescription_1.flowFields,
              ],
          };
          this.methods = {
              loadOptions: {
                  async getLeadStatuses() {
                      const returnData = [];
                      const qs = {
                          q: 'SELECT id, MasterLabel FROM LeadStatus',
                      };
                      const statuses = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                      for (const status of statuses) {
                          const statusName = status.MasterLabel;
                          returnData.push({
                              name: statusName,
                              value: statusName,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getUsers() {
                      const returnData = [];
                      const qs = {
                          q: 'SELECT id, Name FROM User',
                      };
                      const users = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                      for (const user of users) {
                          const userName = user.Name;
                          const userId = user.Id;
                          returnData.push({
                              name: userName,
                              value: userId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCaseOwners() {
                      const returnData = [];
                      const qsQueues = {
                          q: "SELECT Queue.Id, Queue.Name FROM QueuesObject where Queue.Type='Queue' and SobjectType = 'Case'",
                      };
                      const queues = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qsQueues);
                      for (const queue of queues) {
                          const queueName = queue.Queue.Name;
                          const queueId = queue.Queue.Id;
                          returnData.push({
                              name: `Queue: ${queueName}`,
                              value: queueId,
                          });
                      }
                      const qsUsers = {
                          q: 'SELECT id, Name FROM User',
                      };
                      const users = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qsUsers);
                      const userPrefix = returnData.length > 0 ? 'User: ' : '';
                      for (const user of users) {
                          const userName = user.Name;
                          const userId = user.Id;
                          returnData.push({
                              name: userPrefix + userName,
                              value: userId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getLeadOwners() {
                      const returnData = [];
                      const qsQueues = {
                          q: "SELECT Queue.Id, Queue.Name FROM QueuesObject where Queue.Type='Queue' and SobjectType = 'Lead'",
                      };
                      const queues = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qsQueues);
                      for (const queue of queues) {
                          const queueName = queue.Queue.Name;
                          const queueId = queue.Queue.Id;
                          returnData.push({
                              name: `Queue: ${queueName}`,
                              value: queueId,
                          });
                      }
                      const qsUsers = {
                          q: 'SELECT id, Name FROM User',
                      };
                      const users = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qsUsers);
                      const userPrefix = returnData.length > 0 ? 'User: ' : '';
                      for (const user of users) {
                          const userName = user.Name;
                          const userId = user.Id;
                          returnData.push({
                              name: userPrefix + userName,
                              value: userId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getLeadSources() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/lead/describe');
                      for (const field of fields) {
                          if (field.name === 'LeadSource') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCustomFields() {
                      const returnData = [];
                      const resource = this.getNodeParameter('resource', 0);
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/${resource}/describe`);
                      for (const field of fields) {
                          if (field.custom === true) {
                              const fieldName = field.label;
                              const fieldId = field.name;
                              returnData.push({
                                  name: fieldName,
                                  value: fieldId,
                              });
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getRecordTypes() {
                      const returnData = [];
                      let resource = this.getNodeParameter('resource', 0);
                      if (resource === 'customObject') {
                          resource = this.getNodeParameter('customObject', 0);
                      }
                      const qs = {
                          q: `SELECT Id, Name, SobjectType, IsActive FROM RecordType WHERE SobjectType = '${resource}'`,
                      };
                      const types = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                      for (const type of types) {
                          if (type.IsActive === true) {
                              returnData.push({
                                  name: type.Name,
                                  value: type.Id,
                              });
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getExternalIdFields() {
                      const returnData = [];
                      let resource = this.getCurrentNodeParameter('resource');
                      resource =
                          resource === 'customObject'
                              ? this.getCurrentNodeParameter('customObject')
                              : resource;
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/${resource}/describe`);
                      for (const field of fields) {
                          if (field.externalId === true || field.idLookup === true) {
                              const fieldName = field.label;
                              const fieldId = field.name;
                              returnData.push({
                                  name: fieldName,
                                  value: fieldId,
                              });
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getAccounts() {
                      const returnData = [];
                      const qs = {
                          q: 'SELECT id, Name FROM Account',
                      };
                      const accounts = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                      for (const account of accounts) {
                          const accountName = account.Name;
                          const accountId = account.Id;
                          returnData.push({
                              name: accountName,
                              value: accountId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCampaigns() {
                      const returnData = [];
                      const qs = {
                          q: 'SELECT id, Name FROM Campaign',
                      };
                      const campaigns = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                      for (const campaign of campaigns) {
                          const campaignName = campaign.Name;
                          const campaignId = campaign.Id;
                          returnData.push({
                              name: campaignName,
                              value: campaignId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getStages() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/opportunity/describe');
                      for (const field of fields) {
                          if (field.name === 'StageName') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getAccountTypes() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/account/describe');
                      for (const field of fields) {
                          if (field.name === 'Type') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getAccountSources() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/account/describe');
                      for (const field of fields) {
                          if (field.name === 'AccountSource') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCaseTypes() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/case/describe');
                      for (const field of fields) {
                          if (field.name === 'Type') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCaseStatuses() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/case/describe');
                      for (const field of fields) {
                          if (field.name === 'Status') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCaseReasons() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/case/describe');
                      for (const field of fields) {
                          if (field.name === 'Reason') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCaseOrigins() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/case/describe');
                      for (const field of fields) {
                          if (field.name === 'Origin') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCasePriorities() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/case/describe');
                      for (const field of fields) {
                          if (field.name === 'Priority') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getTaskStatuses() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/task/describe');
                      for (const field of fields) {
                          if (field.name === 'Status') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getTaskTypes() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/task/describe');
                      for (const field of fields) {
                          if (field.name === 'TaskSubtype') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getTaskSubjects() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/task/describe');
                      for (const field of fields) {
                          if (field.name === 'Subject') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getTaskCallTypes() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/task/describe');
                      for (const field of fields) {
                          if (field.name === 'CallType') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getTaskPriorities() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/task/describe');
                      for (const field of fields) {
                          if (field.name === 'Priority') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getTaskRecurrenceTypes() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/task/describe');
                      for (const field of fields) {
                          if (field.name === 'RecurrenceType') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getTaskRecurrenceInstances() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/task/describe');
                      for (const field of fields) {
                          if (field.name === 'RecurrenceInstance') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCustomObjects() {
                      const returnData = [];
                      const { sobjects: objects } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects');
                      for (const object of objects) {
                          if (object.custom === true) {
                              const objectName = object.label;
                              const objectId = object.name;
                              returnData.push({
                                  name: objectName,
                                  value: objectId,
                              });
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCustomObjectFields() {
                      const returnData = [];
                      const customObject = this.getCurrentNodeParameter('customObject');
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/${customObject}/describe`);
                      for (const field of fields) {
                          const fieldName = field.label;
                          const fieldId = field.name;
                          returnData.push({
                              name: fieldName,
                              value: fieldId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getAccountFields() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/account/describe');
                      for (const field of fields) {
                          const fieldName = field.label;
                          const fieldId = field.name;
                          returnData.push({
                              name: fieldName,
                              value: fieldId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getAtachmentFields() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/attachment/describe');
                      for (const field of fields) {
                          const fieldName = field.label;
                          const fieldId = field.name;
                          returnData.push({
                              name: fieldName,
                              value: fieldId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCaseFields() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/case/describe');
                      for (const field of fields) {
                          const fieldName = field.label;
                          const fieldId = field.name;
                          returnData.push({
                              name: fieldName,
                              value: fieldId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getLeadFields() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/lead/describe');
                      for (const field of fields) {
                          const fieldName = field.label;
                          const fieldId = field.name;
                          returnData.push({
                              name: fieldName,
                              value: fieldId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getOpportunityFields() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/opportunity/describe');
                      for (const field of fields) {
                          const fieldName = field.label;
                          const fieldId = field.name;
                          returnData.push({
                              name: fieldName,
                              value: fieldId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getTaskFields() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/task/describe');
                      for (const field of fields) {
                          const fieldName = field.label;
                          const fieldId = field.name;
                          returnData.push({
                              name: fieldName,
                              value: fieldId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getUserFields() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/user/describe');
                      for (const field of fields) {
                          const fieldName = field.label;
                          const fieldId = field.name;
                          returnData.push({
                              name: fieldName,
                              value: fieldId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getContactFields() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/contact/describe');
                      for (const field of fields) {
                          const fieldName = field.label;
                          const fieldId = field.name;
                          returnData.push({
                              name: fieldName,
                              value: fieldId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
              },
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          let responseData;
          const qs = {};
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          this.logger.debug(`Running "Salesforce" node named "${this.getNode.name}" resource "${resource}" operation "${operation}"`);
          for (let i = 0; i < items.length; i++) {
              try {
                  if (resource === 'lead') {
                      if (operation === 'create' || operation === 'upsert') {
                          const company = this.getNodeParameter('company', i);
                          const lastname = this.getNodeParameter('lastname', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const body = {
                              Company: company,
                              LastName: lastname,
                          };
                          if (additionalFields.hasOptedOutOfEmail !== undefined) {
                              body.HasOptedOutOfEmail = additionalFields.hasOptedOutOfEmail;
                          }
                          if (additionalFields.hasOptedOutOfFax !== undefined) {
                              body.HasOptedOutOfFax = additionalFields.hasOptedOutOfFax;
                          }
                          if (additionalFields.email !== undefined) {
                              body.Email = additionalFields.email;
                          }
                          if (additionalFields.city !== undefined) {
                              body.City = additionalFields.city;
                          }
                          if (additionalFields.phone !== undefined) {
                              body.Phone = additionalFields.phone;
                          }
                          if (additionalFields.state !== undefined) {
                              body.State = additionalFields.state;
                          }
                          if (additionalFields.title !== undefined) {
                              body.Title = additionalFields.title;
                          }
                          if (additionalFields.jigsaw !== undefined) {
                              body.Jigsaw = additionalFields.jigsaw;
                          }
                          if (additionalFields.rating !== undefined) {
                              body.Rating = additionalFields.rating;
                          }
                          if (additionalFields.status !== undefined) {
                              body.Status = additionalFields.status;
                          }
                          if (additionalFields.street !== undefined) {
                              body.Street = additionalFields.street;
                          }
                          if (additionalFields.country !== undefined) {
                              body.Country = additionalFields.country;
                          }
                          if (additionalFields.owner !== undefined) {
                              body.OwnerId = additionalFields.owner;
                          }
                          if (additionalFields.website !== undefined) {
                              body.Website = additionalFields.website;
                          }
                          if (additionalFields.industry !== undefined) {
                              body.Industry = additionalFields.industry;
                          }
                          if (additionalFields.fax !== undefined) {
                              body.Fax = additionalFields.fax;
                          }
                          if (additionalFields.firstname !== undefined) {
                              body.FirstName = additionalFields.firstname;
                          }
                          if (additionalFields.leadSource !== undefined) {
                              body.LeadSource = additionalFields.leadSource;
                          }
                          if (additionalFields.postalCode !== undefined) {
                              body.PostalCode = additionalFields.postalCode;
                          }
                          if (additionalFields.salutation !== undefined) {
                              body.Salutation = additionalFields.salutation;
                          }
                          if (additionalFields.description !== undefined) {
                              body.Description = additionalFields.description;
                          }
                          if (additionalFields.annualRevenue !== undefined) {
                              body.AnnualRevenue = additionalFields.annualRevenue;
                          }
                          if (additionalFields.isUnreadByOwner !== undefined) {
                              body.IsUnreadByOwner = additionalFields.isUnreadByOwner;
                          }
                          if (additionalFields.numberOfEmployees !== undefined) {
                              body.NumberOfEmployees = additionalFields.numberOfEmployees;
                          }
                          if (additionalFields.mobilePhone !== undefined) {
                              body.MobilePhone = additionalFields.mobilePhone;
                          }
                          if (additionalFields.recordTypeId !== undefined) {
                              body.RecordTypeId = additionalFields.recordTypeId;
                          }
                          if (additionalFields.customFieldsUi) {
                              const customFields = additionalFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          let endpoint = '/sobjects/lead';
                          let method = 'POST';
                          if (operation === 'upsert') {
                              method = 'PATCH';
                              const externalId = this.getNodeParameter('externalId', 0);
                              const externalIdValue = this.getNodeParameter('externalIdValue', i);
                              endpoint = `/sobjects/lead/${externalId}/${externalIdValue}`;
                              if (body[externalId] !== undefined) {
                                  delete body[externalId];
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, method, endpoint, body);
                      }
                      if (operation === 'update') {
                          const leadId = this.getNodeParameter('leadId', i);
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const body = {};
                          if (!Object.keys(updateFields).length) {
                              throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'You must add at least one update field', { itemIndex: i });
                          }
                          if (updateFields.hasOptedOutOfEmail !== undefined) {
                              body.HasOptedOutOfEmail = updateFields.hasOptedOutOfEmail;
                          }
                          if (updateFields.hasOptedOutOfFax !== undefined) {
                              body.hasOptedOutOfFax = updateFields.hasOptedOutOfFax;
                          }
                          if (updateFields.lastname !== undefined) {
                              body.LastName = updateFields.lastname;
                          }
                          if (updateFields.company !== undefined) {
                              body.Company = updateFields.company;
                          }
                          if (updateFields.email !== undefined) {
                              body.Email = updateFields.email;
                          }
                          if (updateFields.city !== undefined) {
                              body.City = updateFields.city;
                          }
                          if (updateFields.phone !== undefined) {
                              body.Phone = updateFields.phone;
                          }
                          if (updateFields.state !== undefined) {
                              body.State = updateFields.state;
                          }
                          if (updateFields.title !== undefined) {
                              body.Title = updateFields.title;
                          }
                          if (updateFields.jigsaw !== undefined) {
                              body.Jigsaw = updateFields.jigsaw;
                          }
                          if (updateFields.rating !== undefined) {
                              body.Rating = updateFields.rating;
                          }
                          if (updateFields.status !== undefined) {
                              body.Status = updateFields.status;
                          }
                          if (updateFields.street !== undefined) {
                              body.Street = updateFields.street;
                          }
                          if (updateFields.country !== undefined) {
                              body.Country = updateFields.country;
                          }
                          if (updateFields.owner !== undefined) {
                              body.OwnerId = updateFields.owner;
                          }
                          if (updateFields.website !== undefined) {
                              body.Website = updateFields.website;
                          }
                          if (updateFields.industry !== undefined) {
                              body.Industry = updateFields.industry;
                          }
                          if (updateFields.firstname !== undefined) {
                              body.FirstName = updateFields.firstname;
                          }
                          if (updateFields.fax !== undefined) {
                              body.Fax = updateFields.fax;
                          }
                          if (updateFields.leadSource !== undefined) {
                              body.LeadSource = updateFields.leadSource;
                          }
                          if (updateFields.postalCode !== undefined) {
                              body.PostalCode = updateFields.postalCode;
                          }
                          if (updateFields.salutation !== undefined) {
                              body.Salutation = updateFields.salutation;
                          }
                          if (updateFields.description !== undefined) {
                              body.Description = updateFields.description;
                          }
                          if (updateFields.annualRevenue !== undefined) {
                              body.AnnualRevenue = updateFields.annualRevenue;
                          }
                          if (updateFields.isUnreadByOwner !== undefined) {
                              body.IsUnreadByOwner = updateFields.isUnreadByOwner;
                          }
                          if (updateFields.numberOfEmployees !== undefined) {
                              body.NumberOfEmployees = updateFields.numberOfEmployees;
                          }
                          if (updateFields.mobilePhone !== undefined) {
                              body.MobilePhone = updateFields.mobilePhone;
                          }
                          if (updateFields.recordTypeId !== undefined) {
                              body.RecordTypeId = updateFields.recordTypeId;
                          }
                          if (updateFields.customFieldsUi) {
                              const customFields = updateFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'PATCH', `/sobjects/lead/${leadId}`, body);
                      }
                      if (operation === 'get') {
                          const leadId = this.getNodeParameter('leadId', i);
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/lead/${leadId}`);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          try {
                              if (returnAll) {
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Lead', returnAll);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                              else {
                                  const limit = this.getNodeParameter('limit', i);
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Lead', returnAll, limit);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'delete') {
                          const leadId = this.getNodeParameter('leadId', i);
                          try {
                              responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'DELETE', `/sobjects/lead/${leadId}`);
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'getSummary') {
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/lead');
                      }
                      if (operation === 'addToCampaign') {
                          const leadId = this.getNodeParameter('leadId', i);
                          const campaignId = this.getNodeParameter('campaignId', i);
                          const options = this.getNodeParameter('options', i);
                          const body = {
                              LeadId: leadId,
                              CampaignId: campaignId,
                          };
                          if (options.status) {
                              body.Status = options.status;
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/CampaignMember', body);
                      }
                      if (operation === 'addNote') {
                          const leadId = this.getNodeParameter('leadId', i);
                          const title = this.getNodeParameter('title', i);
                          const options = this.getNodeParameter('options', i);
                          const body = {
                              Title: title,
                              ParentId: leadId,
                          };
                          if (options.body) {
                              body.Body = options.body;
                          }
                          if (options.owner) {
                              body.OwnerId = options.owner;
                          }
                          if (options.isPrivate) {
                              body.IsPrivate = options.isPrivate;
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/note', body);
                      }
                  }
                  if (resource === 'contact') {
                      if (operation === 'create' || operation === 'upsert') {
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const lastname = this.getNodeParameter('lastname', i);
                          const body = {
                              LastName: lastname,
                          };
                          if (additionalFields.fax !== undefined) {
                              body.Fax = additionalFields.fax;
                          }
                          if (additionalFields.email !== undefined) {
                              body.Email = additionalFields.email;
                          }
                          if (additionalFields.phone !== undefined) {
                              body.Phone = additionalFields.phone;
                          }
                          if (additionalFields.title !== undefined) {
                              body.Title = additionalFields.title;
                          }
                          if (additionalFields.jigsaw !== undefined) {
                              body.Jigsaw = additionalFields.jigsaw;
                          }
                          if (additionalFields.recordTypeId !== undefined) {
                              body.RecordTypeId = additionalFields.recordTypeId;
                          }
                          if (additionalFields.owner !== undefined) {
                              body.OwnerId = additionalFields.owner;
                          }
                          if (additionalFields.acconuntId !== undefined) {
                              body.AccountId = additionalFields.acconuntId;
                          }
                          if (additionalFields.birthdate !== undefined) {
                              body.Birthdate = additionalFields.birthdate;
                          }
                          if (additionalFields.firstName !== undefined) {
                              body.FirstName = additionalFields.firstName;
                          }
                          if (additionalFields.homePhone !== undefined) {
                              body.HomePhone = additionalFields.homePhone;
                          }
                          if (additionalFields.otherCity !== undefined) {
                              body.OtherCity = additionalFields.otherCity;
                          }
                          if (additionalFields.department !== undefined) {
                              body.Department = additionalFields.department;
                          }
                          if (additionalFields.leadSource !== undefined) {
                              body.LeadSource = additionalFields.leadSource;
                          }
                          if (additionalFields.otherPhone !== undefined) {
                              body.OtherPhone = additionalFields.otherPhone;
                          }
                          if (additionalFields.otherState !== undefined) {
                              body.OtherState = additionalFields.otherState;
                          }
                          if (additionalFields.salutation !== undefined) {
                              body.Salutation = additionalFields.salutation;
                          }
                          if (additionalFields.description !== undefined) {
                              body.Description = additionalFields.description;
                          }
                          if (additionalFields.mailingCity !== undefined) {
                              body.MailingCity = additionalFields.mailingCity;
                          }
                          if (additionalFields.mobilePhone !== undefined) {
                              body.MobilePhone = additionalFields.mobilePhone;
                          }
                          if (additionalFields.otherStreet !== undefined) {
                              body.OtherStreet = additionalFields.otherStreet;
                          }
                          if (additionalFields.mailingState !== undefined) {
                              body.MailingState = additionalFields.mailingState;
                          }
                          if (additionalFields.otherCountry !== undefined) {
                              body.OtherCountry = additionalFields.otherCountry;
                          }
                          if (additionalFields.assistantName !== undefined) {
                              body.AssistantName = additionalFields.assistantName;
                          }
                          if (additionalFields.mailingStreet !== undefined) {
                              body.MailingStreet = additionalFields.mailingStreet;
                          }
                          if (additionalFields.assistantPhone !== undefined) {
                              body.AssistantPhone = additionalFields.assistantPhone;
                          }
                          if (additionalFields.mailingCountry !== undefined) {
                              body.MailingCountry = additionalFields.mailingCountry;
                          }
                          if (additionalFields.otherPostalCode !== undefined) {
                              body.OtherPostalCode = additionalFields.otherPostalCode;
                          }
                          if (additionalFields.emailBouncedDate !== undefined) {
                              body.EmailBouncedDate = additionalFields.emailBouncedDate;
                          }
                          if (additionalFields.mailingPostalCode !== undefined) {
                              body.MailingPostalCode = additionalFields.mailingPostalCode;
                          }
                          if (additionalFields.emailBouncedReason !== undefined) {
                              body.EmailBouncedReason = additionalFields.emailBouncedReason;
                          }
                          if (additionalFields.customFieldsUi) {
                              const customFields = additionalFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          let endpoint = '/sobjects/contact';
                          let method = 'POST';
                          if (operation === 'upsert') {
                              method = 'PATCH';
                              const externalId = this.getNodeParameter('externalId', 0);
                              const externalIdValue = this.getNodeParameter('externalIdValue', i);
                              endpoint = `/sobjects/contact/${externalId}/${externalIdValue}`;
                              if (body[externalId] !== undefined) {
                                  delete body[externalId];
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, method, endpoint, body);
                      }
                      if (operation === 'update') {
                          const contactId = this.getNodeParameter('contactId', i);
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const body = {};
                          if (!Object.keys(updateFields).length) {
                              throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'You must add at least one update field', { itemIndex: i });
                          }
                          if (updateFields.lastName !== undefined) {
                              body.LastName = updateFields.lastName;
                          }
                          if (updateFields.fax !== undefined) {
                              body.Fax = updateFields.fax;
                          }
                          if (updateFields.email !== undefined) {
                              body.Email = updateFields.email;
                          }
                          if (updateFields.recordTypeId !== undefined) {
                              body.RecordTypeId = updateFields.recordTypeId;
                          }
                          if (updateFields.phone !== undefined) {
                              body.Phone = updateFields.phone;
                          }
                          if (updateFields.title !== undefined) {
                              body.Title = updateFields.title;
                          }
                          if (updateFields.jigsaw !== undefined) {
                              body.Jigsaw = updateFields.jigsaw;
                          }
                          if (updateFields.owner !== undefined) {
                              body.OwnerId = updateFields.owner;
                          }
                          if (updateFields.acconuntId !== undefined) {
                              body.AccountId = updateFields.acconuntId;
                          }
                          if (updateFields.birthdate !== undefined) {
                              body.Birthdate = updateFields.birthdate;
                          }
                          if (updateFields.firstName !== undefined) {
                              body.FirstName = updateFields.firstName;
                          }
                          if (updateFields.homePhone !== undefined) {
                              body.HomePhone = updateFields.homePhone;
                          }
                          if (updateFields.otherCity !== undefined) {
                              body.OtherCity = updateFields.otherCity;
                          }
                          if (updateFields.department !== undefined) {
                              body.Department = updateFields.department;
                          }
                          if (updateFields.leadSource !== undefined) {
                              body.LeadSource = updateFields.leadSource;
                          }
                          if (updateFields.otherPhone !== undefined) {
                              body.OtherPhone = updateFields.otherPhone;
                          }
                          if (updateFields.otherState !== undefined) {
                              body.OtherState = updateFields.otherState;
                          }
                          if (updateFields.salutation !== undefined) {
                              body.Salutation = updateFields.salutation;
                          }
                          if (updateFields.description !== undefined) {
                              body.Description = updateFields.description;
                          }
                          if (updateFields.mailingCity !== undefined) {
                              body.MailingCity = updateFields.mailingCity;
                          }
                          if (updateFields.mobilePhone !== undefined) {
                              body.MobilePhone = updateFields.mobilePhone;
                          }
                          if (updateFields.otherStreet !== undefined) {
                              body.OtherStreet = updateFields.otherStreet;
                          }
                          if (updateFields.mailingState !== undefined) {
                              body.MailingState = updateFields.mailingState;
                          }
                          if (updateFields.otherCountry !== undefined) {
                              body.OtherCountry = updateFields.otherCountry;
                          }
                          if (updateFields.assistantName !== undefined) {
                              body.AssistantName = updateFields.assistantName;
                          }
                          if (updateFields.mailingStreet !== undefined) {
                              body.MailingStreet = updateFields.mailingStreet;
                          }
                          if (updateFields.assistantPhone !== undefined) {
                              body.AssistantPhone = updateFields.assistantPhone;
                          }
                          if (updateFields.mailingCountry !== undefined) {
                              body.MailingCountry = updateFields.mailingCountry;
                          }
                          if (updateFields.otherPostalCode !== undefined) {
                              body.OtherPostalCode = updateFields.otherPostalCode;
                          }
                          if (updateFields.emailBouncedDate !== undefined) {
                              body.EmailBouncedDate = updateFields.emailBouncedDate;
                          }
                          if (updateFields.mailingPostalCode !== undefined) {
                              body.MailingPostalCode = updateFields.mailingPostalCode;
                          }
                          if (updateFields.emailBouncedReason !== undefined) {
                              body.EmailBouncedReason = updateFields.emailBouncedReason;
                          }
                          if (updateFields.customFieldsUi) {
                              const customFields = updateFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'PATCH', `/sobjects/contact/${contactId}`, body);
                      }
                      if (operation === 'get') {
                          const contactId = this.getNodeParameter('contactId', i);
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/contact/${contactId}`);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          try {
                              if (returnAll) {
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Contact', returnAll);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                              else {
                                  const limit = this.getNodeParameter('limit', i);
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Contact', returnAll, limit);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'delete') {
                          const contactId = this.getNodeParameter('contactId', i);
                          try {
                              responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'DELETE', `/sobjects/contact/${contactId}`);
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'getSummary') {
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/contact');
                      }
                      if (operation === 'addToCampaign') {
                          const contactId = this.getNodeParameter('contactId', i);
                          const campaignId = this.getNodeParameter('campaignId', i);
                          const options = this.getNodeParameter('options', i);
                          const body = {
                              ContactId: contactId,
                              CampaignId: campaignId,
                          };
                          if (options.status) {
                              body.Status = options.status;
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/CampaignMember', body);
                      }
                      if (operation === 'addNote') {
                          const contactId = this.getNodeParameter('contactId', i);
                          const title = this.getNodeParameter('title', i);
                          const options = this.getNodeParameter('options', i);
                          const body = {
                              Title: title,
                              ParentId: contactId,
                          };
                          if (options.body !== undefined) {
                              body.Body = options.body;
                          }
                          if (options.owner !== undefined) {
                              body.OwnerId = options.owner;
                          }
                          if (options.isPrivate !== undefined) {
                              body.IsPrivate = options.isPrivate;
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/note', body);
                      }
                  }
                  if (resource === 'customObject') {
                      if (operation === 'create' || operation === 'upsert') {
                          const customObject = this.getNodeParameter('customObject', i);
                          const customFieldsUi = this.getNodeParameter('customFieldsUi', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const body = {};
                          if (customFieldsUi) {
                              const customFields = customFieldsUi.customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          if (additionalFields.recordTypeId) {
                              body.RecordTypeId = additionalFields.recordTypeId;
                          }
                          let endpoint = `/sobjects/${customObject}`;
                          let method = 'POST';
                          if (operation === 'upsert') {
                              method = 'PATCH';
                              const externalId = this.getNodeParameter('externalId', 0);
                              const externalIdValue = this.getNodeParameter('externalIdValue', i);
                              endpoint = `/sobjects/${customObject}/${externalId}/${externalIdValue}`;
                              if (body[externalId] !== undefined) {
                                  delete body[externalId];
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, method, endpoint, body);
                      }
                      if (operation === 'update') {
                          const recordId = this.getNodeParameter('recordId', i);
                          const customObject = this.getNodeParameter('customObject', i);
                          const customFieldsUi = this.getNodeParameter('customFieldsUi', i);
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const body = {};
                          if (updateFields.recordTypeId) {
                              body.RecordTypeId = updateFields.recordTypeId;
                          }
                          if (customFieldsUi) {
                              const customFields = customFieldsUi.customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'PATCH', `/sobjects/${customObject}/${recordId}`, body);
                      }
                      if (operation === 'get') {
                          const customObject = this.getNodeParameter('customObject', i);
                          const recordId = this.getNodeParameter('recordId', i);
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/${customObject}/${recordId}`);
                      }
                      if (operation === 'getAll') {
                          const customObject = this.getNodeParameter('customObject', i);
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          try {
                              if (returnAll) {
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, customObject, returnAll);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                              else {
                                  const limit = this.getNodeParameter('limit', i);
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, customObject, returnAll, limit);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'delete') {
                          const customObject = this.getNodeParameter('customObject', i);
                          const recordId = this.getNodeParameter('recordId', i);
                          try {
                              responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'DELETE', `/sobjects/${customObject}/${recordId}`);
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                  }
                  if (resource === 'document') {
                      if (operation === 'upload') {
                          const title = this.getNodeParameter('title', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
                          const body = {
                              entity_content: {
                                  Title: title,
                                  ContentLocation: 'S',
                              },
                          };
                          if (additionalFields.ownerId) {
                              body.entity_content.ownerId = additionalFields.ownerId;
                          }
                          if (additionalFields.linkToObjectId) {
                              body.entity_content.FirstPublishLocationId =
                                  additionalFields.linkToObjectId;
                          }
                          const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
                          const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
                          body.entity_content.PathOnClient = `${title}.${additionalFields.fileExtension || binaryData.fileExtension}`;
                          const data = {
                              entity_content: {
                                  value: JSON.stringify(body.entity_content),
                                  options: {
                                      contentType: 'application/json',
                                  },
                              },
                              VersionData: {
                                  value: dataBuffer,
                                  options: {
                                      filename: body.entity_content.PathOnClient,
                                  },
                              },
                          };
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/ContentVersion', {}, {}, undefined, { formData: data });
                      }
                  }
                  if (resource === 'opportunity') {
                      if (operation === 'create' || operation === 'upsert') {
                          const name = this.getNodeParameter('name', i);
                          const closeDate = this.getNodeParameter('closeDate', i);
                          const stageName = this.getNodeParameter('stageName', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const body = {
                              Name: name,
                              CloseDate: closeDate,
                              StageName: stageName,
                          };
                          if (additionalFields.type !== undefined) {
                              body.Type = additionalFields.type;
                          }
                          if (additionalFields.amount !== undefined) {
                              body.Amount = additionalFields.amount;
                          }
                          if (additionalFields.owner !== undefined) {
                              body.OwnerId = additionalFields.owner;
                          }
                          if (additionalFields.nextStep !== undefined) {
                              body.NextStep = additionalFields.nextStep;
                          }
                          if (additionalFields.accountId !== undefined) {
                              body.AccountId = additionalFields.accountId;
                          }
                          if (additionalFields.campaignId !== undefined) {
                              body.CampaignId = additionalFields.campaignId;
                          }
                          if (additionalFields.leadSource !== undefined) {
                              body.LeadSource = additionalFields.leadSource;
                          }
                          if (additionalFields.description !== undefined) {
                              body.Description = additionalFields.description;
                          }
                          if (additionalFields.probability !== undefined) {
                              body.Probability = additionalFields.probability;
                          }
                          if (additionalFields.pricebook2Id !== undefined) {
                              body.Pricebook2Id = additionalFields.pricebook2Id;
                          }
                          if (additionalFields.forecastCategoryName !== undefined) {
                              body.ForecastCategoryName = additionalFields.forecastCategoryName;
                          }
                          if (additionalFields.customFieldsUi) {
                              const customFields = additionalFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          let endpoint = '/sobjects/opportunity';
                          let method = 'POST';
                          if (operation === 'upsert') {
                              method = 'PATCH';
                              const externalId = this.getNodeParameter('externalId', 0);
                              const externalIdValue = this.getNodeParameter('externalIdValue', i);
                              endpoint = `/sobjects/opportunity/${externalId}/${externalIdValue}`;
                              if (body[externalId] !== undefined) {
                                  delete body[externalId];
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, method, endpoint, body);
                      }
                      if (operation === 'update') {
                          const opportunityId = this.getNodeParameter('opportunityId', i);
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const body = {};
                          if (updateFields.name !== undefined) {
                              body.Name = updateFields.name;
                          }
                          if (updateFields.closeDate !== undefined) {
                              body.CloseDate = updateFields.closeDate;
                          }
                          if (updateFields.stageName !== undefined) {
                              body.StageName = updateFields.stageName;
                          }
                          if (updateFields.type !== undefined) {
                              body.Type = updateFields.type;
                          }
                          if (updateFields.amount !== undefined) {
                              body.Amount = updateFields.amount;
                          }
                          if (updateFields.owner !== undefined) {
                              body.OwnerId = updateFields.owner;
                          }
                          if (updateFields.nextStep !== undefined) {
                              body.NextStep = updateFields.nextStep;
                          }
                          if (updateFields.accountId !== undefined) {
                              body.AccountId = updateFields.accountId;
                          }
                          if (updateFields.campaignId !== undefined) {
                              body.CampaignId = updateFields.campaignId;
                          }
                          if (updateFields.leadSource !== undefined) {
                              body.LeadSource = updateFields.leadSource;
                          }
                          if (updateFields.description !== undefined) {
                              body.Description = updateFields.description;
                          }
                          if (updateFields.probability !== undefined) {
                              body.Probability = updateFields.probability;
                          }
                          if (updateFields.pricebook2Id !== undefined) {
                              body.Pricebook2Id = updateFields.pricebook2Id;
                          }
                          if (updateFields.forecastCategoryName !== undefined) {
                              body.ForecastCategoryName = updateFields.forecastCategoryName;
                          }
                          if (updateFields.customFieldsUi) {
                              const customFields = updateFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'PATCH', `/sobjects/opportunity/${opportunityId}`, body);
                      }
                      if (operation === 'get') {
                          const opportunityId = this.getNodeParameter('opportunityId', i);
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/opportunity/${opportunityId}`);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          try {
                              if (returnAll) {
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Opportunity', returnAll);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                              else {
                                  const limit = this.getNodeParameter('limit', i);
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Opportunity', returnAll, limit);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'delete') {
                          const opportunityId = this.getNodeParameter('opportunityId', i);
                          try {
                              responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'DELETE', `/sobjects/opportunity/${opportunityId}`);
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'getSummary') {
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/opportunity');
                      }
                      if (operation === 'addNote') {
                          const opportunityId = this.getNodeParameter('opportunityId', i);
                          const title = this.getNodeParameter('title', i);
                          const options = this.getNodeParameter('options', i);
                          const body = {
                              Title: title,
                              ParentId: opportunityId,
                          };
                          if (options.body !== undefined) {
                              body.Body = options.body;
                          }
                          if (options.owner !== undefined) {
                              body.OwnerId = options.owner;
                          }
                          if (options.isPrivate !== undefined) {
                              body.IsPrivate = options.isPrivate;
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/note', body);
                      }
                  }
                  if (resource === 'account') {
                      if (operation === 'create' || operation === 'upsert') {
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const name = this.getNodeParameter('name', i);
                          const body = {
                              Name: name,
                          };
                          if (additionalFields.fax !== undefined) {
                              body.Fax = additionalFields.fax;
                          }
                          if (additionalFields.type !== undefined) {
                              body.Type = additionalFields.type;
                          }
                          if (additionalFields.jigsaw !== undefined) {
                              body.Jigsaw = additionalFields.jigsaw;
                          }
                          if (additionalFields.phone !== undefined) {
                              body.Phone = additionalFields.phone;
                          }
                          if (additionalFields.owner !== undefined) {
                              body.OwnerId = additionalFields.owner;
                          }
                          if (additionalFields.sicDesc !== undefined) {
                              body.SicDesc = additionalFields.sicDesc;
                          }
                          if (additionalFields.website !== undefined) {
                              body.Website = additionalFields.website;
                          }
                          if (additionalFields.industry !== undefined) {
                              body.Industry = additionalFields.industry;
                          }
                          if (additionalFields.parentId !== undefined) {
                              body.ParentId = additionalFields.parentId;
                          }
                          if (additionalFields.billingCity !== undefined) {
                              body.BillingCity = additionalFields.billingCity;
                          }
                          if (additionalFields.description !== undefined) {
                              body.Description = additionalFields.description;
                          }
                          if (additionalFields.billingState !== undefined) {
                              body.BillingState = additionalFields.billingState;
                          }
                          if (additionalFields.shippingCity !== undefined) {
                              body.ShippingCity = additionalFields.shippingCity;
                          }
                          if (additionalFields.accountNumber !== undefined) {
                              body.AccountNumber = additionalFields.accountNumber;
                          }
                          if (additionalFields.accountSource !== undefined) {
                              body.AccountSource = additionalFields.accountSource;
                          }
                          if (additionalFields.annualRevenue !== undefined) {
                              body.AnnualRevenue = additionalFields.annualRevenue;
                          }
                          if (additionalFields.billingStreet !== undefined) {
                              body.BillingStreet = additionalFields.billingStreet;
                          }
                          if (additionalFields.shippingState !== undefined) {
                              body.ShippingState = additionalFields.shippingState;
                          }
                          if (additionalFields.billingCountry !== undefined) {
                              body.BillingCountry = additionalFields.billingCountry;
                          }
                          if (additionalFields.shippingStreet !== undefined) {
                              body.ShippingStreet = additionalFields.shippingStreet;
                          }
                          if (additionalFields.shippingCountry !== undefined) {
                              body.ShippingCountry = additionalFields.shippingCountry;
                          }
                          if (additionalFields.billingPostalCode !== undefined) {
                              body.BillingPostalCode = additionalFields.billingPostalCode;
                          }
                          if (additionalFields.numberOfEmployees !== undefined) {
                              body.NumberOfEmployees = additionalFields.numberOfEmployees;
                          }
                          if (additionalFields.shippingPostalCode !== undefined) {
                              body.ShippingPostalCode = additionalFields.shippingPostalCode;
                          }
                          if (additionalFields.shippingPostalCode !== undefined) {
                              body.ShippingPostalCode = additionalFields.shippingPostalCode;
                          }
                          if (additionalFields.recordTypeId !== undefined) {
                              body.RecordTypeId = additionalFields.recordTypeId;
                          }
                          if (additionalFields.customFieldsUi) {
                              const customFields = additionalFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          let endpoint = '/sobjects/account';
                          let method = 'POST';
                          if (operation === 'upsert') {
                              method = 'PATCH';
                              const externalId = this.getNodeParameter('externalId', 0);
                              const externalIdValue = this.getNodeParameter('externalIdValue', i);
                              endpoint = `/sobjects/account/${externalId}/${externalIdValue}`;
                              if (body[externalId] !== undefined) {
                                  delete body[externalId];
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, method, endpoint, body);
                      }
                      if (operation === 'update') {
                          const accountId = this.getNodeParameter('accountId', i);
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const body = {};
                          if (updateFields.name !== undefined) {
                              body.Name = updateFields.name;
                          }
                          if (updateFields.fax !== undefined) {
                              body.Fax = updateFields.fax;
                          }
                          if (updateFields.type !== undefined) {
                              body.Type = updateFields.type;
                          }
                          if (updateFields.jigsaw !== undefined) {
                              body.Jigsaw = updateFields.jigsaw;
                          }
                          if (updateFields.phone !== undefined) {
                              body.Phone = updateFields.phone;
                          }
                          if (updateFields.ownerId !== undefined) {
                              body.OwnerId = updateFields.ownerId;
                          }
                          if (updateFields.sicDesc !== undefined) {
                              body.SicDesc = updateFields.sicDesc;
                          }
                          if (updateFields.recordTypeId !== undefined) {
                              body.RecordTypeId = updateFields.recordTypeId;
                          }
                          if (updateFields.website !== undefined) {
                              body.Website = updateFields.website;
                          }
                          if (updateFields.industry !== undefined) {
                              body.Industry = updateFields.industry;
                          }
                          if (updateFields.parentId !== undefined) {
                              body.ParentId = updateFields.parentId;
                          }
                          if (updateFields.billingCity !== undefined) {
                              body.BillingCity = updateFields.billingCity;
                          }
                          if (updateFields.description !== undefined) {
                              body.Description = updateFields.description;
                          }
                          if (updateFields.billingState !== undefined) {
                              body.BillingState = updateFields.billingState;
                          }
                          if (updateFields.shippingCity !== undefined) {
                              body.ShippingCity = updateFields.shippingCity;
                          }
                          if (updateFields.accountNumber !== undefined) {
                              body.AccountNumber = updateFields.accountNumber;
                          }
                          if (updateFields.accountSource !== undefined) {
                              body.AccountSource = updateFields.accountSource;
                          }
                          if (updateFields.annualRevenue !== undefined) {
                              body.AnnualRevenue = updateFields.annualRevenue;
                          }
                          if (updateFields.billingStreet !== undefined) {
                              body.BillingStreet = updateFields.billingStreet;
                          }
                          if (updateFields.shippingState !== undefined) {
                              body.ShippingState = updateFields.shippingState;
                          }
                          if (updateFields.billingCountry !== undefined) {
                              body.BillingCountry = updateFields.billingCountry;
                          }
                          if (updateFields.shippingStreet !== undefined) {
                              body.ShippingStreet = updateFields.shippingStreet;
                          }
                          if (updateFields.shippingCountry !== undefined) {
                              body.ShippingCountry = updateFields.shippingCountry;
                          }
                          if (updateFields.billingPostalCode !== undefined) {
                              body.BillingPostalCode = updateFields.billingPostalCode;
                          }
                          if (updateFields.numberOfEmployees !== undefined) {
                              body.NumberOfEmployees = updateFields.numberOfEmployees;
                          }
                          if (updateFields.shippingPostalCode !== undefined) {
                              body.ShippingPostalCode = updateFields.shippingPostalCode;
                          }
                          if (updateFields.shippingPostalCode !== undefined) {
                              body.ShippingPostalCode = updateFields.shippingPostalCode;
                          }
                          if (updateFields.customFieldsUi) {
                              const customFields = updateFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'PATCH', `/sobjects/account/${accountId}`, body);
                      }
                      if (operation === 'get') {
                          const accountId = this.getNodeParameter('accountId', i);
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/account/${accountId}`);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          try {
                              if (returnAll) {
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Account', returnAll);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                              else {
                                  const limit = this.getNodeParameter('limit', i);
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Account', returnAll, limit);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'delete') {
                          const accountId = this.getNodeParameter('accountId', i);
                          try {
                              responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'DELETE', `/sobjects/account/${accountId}`);
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'getSummary') {
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/account');
                      }
                      if (operation === 'addNote') {
                          const accountId = this.getNodeParameter('accountId', i);
                          const title = this.getNodeParameter('title', i);
                          const options = this.getNodeParameter('options', i);
                          const body = {
                              Title: title,
                              ParentId: accountId,
                          };
                          if (options.body !== undefined) {
                              body.Body = options.body;
                          }
                          if (options.owner !== undefined) {
                              body.OwnerId = options.owner;
                          }
                          if (options.isPrivate !== undefined) {
                              body.IsPrivate = options.isPrivate;
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/note', body);
                      }
                  }
                  if (resource === 'case') {
                      if (operation === 'create') {
                          const type = this.getNodeParameter('type', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const body = {
                              Type: type,
                          };
                          if (additionalFields.origin !== undefined) {
                              body.Origin = additionalFields.origin;
                          }
                          if (additionalFields.reason !== undefined) {
                              body.Reason = additionalFields.reason;
                          }
                          if (additionalFields.status !== undefined) {
                              body.Status = additionalFields.status;
                          }
                          if (additionalFields.owner !== undefined) {
                              body.OwnerId = additionalFields.owner;
                          }
                          if (additionalFields.subject !== undefined) {
                              body.Subject = additionalFields.subject;
                          }
                          if (additionalFields.parentId !== undefined) {
                              body.ParentId = additionalFields.parentId;
                          }
                          if (additionalFields.priority !== undefined) {
                              body.Priority = additionalFields.priority;
                          }
                          if (additionalFields.accountId !== undefined) {
                              body.AccountId = additionalFields.accountId;
                          }
                          if (additionalFields.contactId !== undefined) {
                              body.ContactId = additionalFields.contactId;
                          }
                          if (additionalFields.description !== undefined) {
                              body.Description = additionalFields.description;
                          }
                          if (additionalFields.isEscalated !== undefined) {
                              body.IsEscalated = additionalFields.isEscalated;
                          }
                          if (additionalFields.suppliedName !== undefined) {
                              body.SuppliedName = additionalFields.suppliedName;
                          }
                          if (additionalFields.suppliedEmail !== undefined) {
                              body.SuppliedEmail = additionalFields.suppliedEmail;
                          }
                          if (additionalFields.suppliedPhone !== undefined) {
                              body.SuppliedPhone = additionalFields.suppliedPhone;
                          }
                          if (additionalFields.suppliedCompany !== undefined) {
                              body.SuppliedCompany = additionalFields.suppliedCompany;
                          }
                          if (additionalFields.recordTypeId !== undefined) {
                              body.RecordTypeId = additionalFields.recordTypeId;
                          }
                          if (additionalFields.customFieldsUi) {
                              const customFields = additionalFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/case', body);
                      }
                      if (operation === 'update') {
                          const caseId = this.getNodeParameter('caseId', i);
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const body = {};
                          if (updateFields.type !== undefined) {
                              body.Type = updateFields.type;
                          }
                          if (updateFields.origin !== undefined) {
                              body.Origin = updateFields.origin;
                          }
                          if (updateFields.reason !== undefined) {
                              body.Reason = updateFields.reason;
                          }
                          if (updateFields.status !== undefined) {
                              body.Status = updateFields.status;
                          }
                          if (updateFields.owner !== undefined) {
                              body.OwnerId = updateFields.owner;
                          }
                          if (updateFields.subject !== undefined) {
                              body.Subject = updateFields.subject;
                          }
                          if (updateFields.parentId !== undefined) {
                              body.ParentId = updateFields.parentId;
                          }
                          if (updateFields.priority !== undefined) {
                              body.Priority = updateFields.priority;
                          }
                          if (updateFields.accountId !== undefined) {
                              body.AccountId = updateFields.accountId;
                          }
                          if (updateFields.recordTypeId !== undefined) {
                              body.RecordTypeId = updateFields.recordTypeId;
                          }
                          if (updateFields.contactId !== undefined) {
                              body.ContactId = updateFields.contactId;
                          }
                          if (updateFields.description !== undefined) {
                              body.Description = updateFields.description;
                          }
                          if (updateFields.isEscalated !== undefined) {
                              body.IsEscalated = updateFields.isEscalated;
                          }
                          if (updateFields.suppliedName !== undefined) {
                              body.SuppliedName = updateFields.suppliedName;
                          }
                          if (updateFields.suppliedEmail !== undefined) {
                              body.SuppliedEmail = updateFields.suppliedEmail;
                          }
                          if (updateFields.suppliedPhone !== undefined) {
                              body.SuppliedPhone = updateFields.suppliedPhone;
                          }
                          if (updateFields.suppliedCompany !== undefined) {
                              body.SuppliedCompany = updateFields.suppliedCompany;
                          }
                          if (updateFields.customFieldsUi) {
                              const customFields = updateFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'PATCH', `/sobjects/case/${caseId}`, body);
                      }
                      if (operation === 'get') {
                          const caseId = this.getNodeParameter('caseId', i);
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/case/${caseId}`);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          try {
                              if (returnAll) {
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Case', returnAll);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                              else {
                                  const limit = this.getNodeParameter('limit', i);
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Case', returnAll, limit);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'delete') {
                          const caseId = this.getNodeParameter('caseId', i);
                          try {
                              responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'DELETE', `/sobjects/case/${caseId}`);
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'getSummary') {
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/case');
                      }
                      if (operation === 'addComment') {
                          const caseId = this.getNodeParameter('caseId', i);
                          const options = this.getNodeParameter('options', i);
                          const body = {
                              ParentId: caseId,
                          };
                          if (options.commentBody !== undefined) {
                              body.CommentBody = options.commentBody;
                          }
                          if (options.isPublished !== undefined) {
                              body.IsPublished = options.isPublished;
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/casecomment', body);
                      }
                  }
                  if (resource === 'task') {
                      if (operation === 'create') {
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const status = this.getNodeParameter('status', i);
                          const body = {
                              Status: status,
                          };
                          if (additionalFields.type !== undefined) {
                              body.TaskSubtype = additionalFields.type;
                          }
                          if (additionalFields.whoId !== undefined) {
                              body.WhoId = additionalFields.whoId;
                          }
                          if (additionalFields.whatId !== undefined) {
                              body.WhatId = additionalFields.whatId;
                          }
                          if (additionalFields.owner !== undefined) {
                              body.OwnerId = additionalFields.owner;
                          }
                          if (additionalFields.subject !== undefined) {
                              body.Subject = additionalFields.subject;
                          }
                          if (additionalFields.callType !== undefined) {
                              body.CallType = additionalFields.callType;
                          }
                          if (additionalFields.priority !== undefined) {
                              body.Priority = additionalFields.priority;
                          }
                          if (additionalFields.callObject !== undefined) {
                              body.CallObject = additionalFields.callObject;
                          }
                          if (additionalFields.description !== undefined) {
                              body.Description = additionalFields.description;
                          }
                          if (additionalFields.activityDate !== undefined) {
                              body.ActivityDate = additionalFields.activityDate;
                          }
                          if (additionalFields.isReminderSet !== undefined) {
                              body.IsReminderSet = additionalFields.isReminderSet;
                          }
                          if (additionalFields.recurrenceType !== undefined) {
                              body.RecurrenceType = additionalFields.recurrenceType;
                          }
                          if (additionalFields.callDisposition !== undefined) {
                              body.CallDisposition = additionalFields.callDisposition;
                          }
                          if (additionalFields.reminderDateTime !== undefined) {
                              body.ReminderDateTime = additionalFields.reminderDateTime;
                          }
                          if (additionalFields.recurrenceInstance !== undefined) {
                              body.RecurrenceInstance = additionalFields.recurrenceInstance;
                          }
                          if (additionalFields.recurrenceInterval !== undefined) {
                              body.RecurrenceInterval = additionalFields.recurrenceInterval;
                          }
                          if (additionalFields.recurrenceDayOfMonth !== undefined) {
                              body.RecurrenceDayOfMonth = additionalFields.recurrenceDayOfMonth;
                          }
                          if (additionalFields.callDurationInSeconds !== undefined) {
                              body.CallDurationInSeconds = additionalFields.callDurationInSeconds;
                          }
                          if (additionalFields.recurrenceEndDateOnly !== undefined) {
                              body.RecurrenceEndDateOnly = additionalFields.recurrenceEndDateOnly;
                          }
                          if (additionalFields.recurrenceMonthOfYear !== undefined) {
                              body.RecurrenceMonthOfYear = additionalFields.recurrenceMonthOfYear;
                          }
                          if (additionalFields.recurrenceDayOfWeekMask !== undefined) {
                              body.RecurrenceDayOfWeekMask = additionalFields.recurrenceDayOfWeekMask;
                          }
                          if (additionalFields.recurrenceStartDateOnly !== undefined) {
                              body.RecurrenceStartDateOnly = additionalFields.recurrenceStartDateOnly;
                          }
                          if (additionalFields.recurrenceTimeZoneSidKey !== undefined) {
                              body.RecurrenceTimeZoneSidKey = additionalFields.recurrenceTimeZoneSidKey;
                          }
                          if (additionalFields.recurrenceRegeneratedType !== undefined) {
                              body.RecurrenceRegeneratedType = additionalFields.recurrenceRegeneratedType;
                          }
                          if (additionalFields.customFieldsUi) {
                              const customFields = additionalFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/task', body);
                      }
                      if (operation === 'update') {
                          const taskId = this.getNodeParameter('taskId', i);
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const body = {};
                          if (updateFields.type !== undefined) {
                              body.TaskSubtype = updateFields.type;
                          }
                          if (updateFields.whoId !== undefined) {
                              body.WhoId = updateFields.whoId;
                          }
                          if (updateFields.status !== undefined) {
                              body.Status = updateFields.status;
                          }
                          if (updateFields.whatId !== undefined) {
                              body.WhatId = updateFields.whatId;
                          }
                          if (updateFields.owner !== undefined) {
                              body.OwnerId = updateFields.owner;
                          }
                          if (updateFields.subject !== undefined) {
                              body.Subject = updateFields.subject;
                          }
                          if (updateFields.callType !== undefined) {
                              body.CallType = updateFields.callType;
                          }
                          if (updateFields.priority !== undefined) {
                              body.Priority = updateFields.priority;
                          }
                          if (updateFields.callObject !== undefined) {
                              body.CallObject = updateFields.callObject;
                          }
                          if (updateFields.description !== undefined) {
                              body.Description = updateFields.description;
                          }
                          if (updateFields.activityDate !== undefined) {
                              body.ActivityDate = updateFields.activityDate;
                          }
                          if (updateFields.isReminderSet !== undefined) {
                              body.IsReminderSet = updateFields.isReminderSet;
                          }
                          if (updateFields.recurrenceType !== undefined) {
                              body.RecurrenceType = updateFields.recurrenceType;
                          }
                          if (updateFields.callDisposition !== undefined) {
                              body.CallDisposition = updateFields.callDisposition;
                          }
                          if (updateFields.reminderDateTime !== undefined) {
                              body.ReminderDateTime = updateFields.reminderDateTime;
                          }
                          if (updateFields.recurrenceInstance !== undefined) {
                              body.RecurrenceInstance = updateFields.recurrenceInstance;
                          }
                          if (updateFields.recurrenceInterval !== undefined) {
                              body.RecurrenceInterval = updateFields.recurrenceInterval;
                          }
                          if (updateFields.recurrenceDayOfMonth !== undefined) {
                              body.RecurrenceDayOfMonth = updateFields.recurrenceDayOfMonth;
                          }
                          if (updateFields.callDurationInSeconds !== undefined) {
                              body.CallDurationInSeconds = updateFields.callDurationInSeconds;
                          }
                          if (updateFields.recurrenceEndDateOnly !== undefined) {
                              body.RecurrenceEndDateOnly = updateFields.recurrenceEndDateOnly;
                          }
                          if (updateFields.recurrenceMonthOfYear !== undefined) {
                              body.RecurrenceMonthOfYear = updateFields.recurrenceMonthOfYear;
                          }
                          if (updateFields.recurrenceDayOfWeekMask !== undefined) {
                              body.RecurrenceDayOfWeekMask = updateFields.recurrenceDayOfWeekMask;
                          }
                          if (updateFields.recurrenceStartDateOnly !== undefined) {
                              body.RecurrenceStartDateOnly = updateFields.recurrenceStartDateOnly;
                          }
                          if (updateFields.recurrenceTimeZoneSidKey !== undefined) {
                              body.RecurrenceTimeZoneSidKey = updateFields.recurrenceTimeZoneSidKey;
                          }
                          if (updateFields.recurrenceRegeneratedType !== undefined) {
                              body.RecurrenceRegeneratedType = updateFields.recurrenceRegeneratedType;
                          }
                          if (updateFields.customFieldsUi) {
                              const customFields = updateFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'PATCH', `/sobjects/task/${taskId}`, body);
                      }
                      if (operation === 'get') {
                          const taskId = this.getNodeParameter('taskId', i);
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/task/${taskId}`);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          try {
                              if (returnAll) {
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Task', returnAll);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                              else {
                                  const limit = this.getNodeParameter('limit', i);
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Task', returnAll, limit);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'delete') {
                          const taskId = this.getNodeParameter('taskId', i);
                          try {
                              responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'DELETE', `/sobjects/task/${taskId}`);
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'getSummary') {
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/task');
                      }
                  }
                  if (resource === 'attachment') {
                      if (operation === 'create') {
                          const name = this.getNodeParameter('name', i);
                          const parentId = this.getNodeParameter('parentId', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
                          const body = {
                              Name: name,
                              ParentId: parentId,
                          };
                          if (items[i].binary && items[i].binary[binaryPropertyName]) {
                              body.Body = items[i].binary[binaryPropertyName].data;
                              body.ContentType = items[i].binary[binaryPropertyName].mimeType;
                          }
                          else {
                              throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The property ${binaryPropertyName} does not exist`, { itemIndex: i });
                          }
                          if (additionalFields.description !== undefined) {
                              body.Description = additionalFields.description;
                          }
                          if (additionalFields.owner !== undefined) {
                              body.OwnerId = additionalFields.owner;
                          }
                          if (additionalFields.isPrivate !== undefined) {
                              body.IsPrivate = additionalFields.isPrivate;
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/attachment', body);
                      }
                      if (operation === 'update') {
                          const attachmentId = this.getNodeParameter('attachmentId', i);
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const body = {};
                          if (updateFields.binaryPropertyName !== undefined) {
                              const binaryPropertyName = updateFields.binaryPropertyName;
                              if (items[i].binary && items[i].binary[binaryPropertyName]) {
                                  body.Body = items[i].binary[binaryPropertyName].data;
                                  body.ContentType = items[i].binary[binaryPropertyName].mimeType;
                              }
                              else {
                                  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The property ${binaryPropertyName} does not exist`, { itemIndex: i });
                              }
                          }
                          if (updateFields.name !== undefined) {
                              body.Name = updateFields.name;
                          }
                          if (updateFields.description !== undefined) {
                              body.Description = updateFields.description;
                          }
                          if (updateFields.owner !== undefined) {
                              body.OwnerId = updateFields.owner;
                          }
                          if (updateFields.isPrivate !== undefined) {
                              body.IsPrivate = updateFields.isPrivate;
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'PATCH', `/sobjects/attachment/${attachmentId}`, body);
                      }
                      if (operation === 'get') {
                          const attachmentId = this.getNodeParameter('attachmentId', i);
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/attachment/${attachmentId}`);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          try {
                              if (returnAll) {
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Attachment', returnAll);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                              else {
                                  const limit = this.getNodeParameter('limit', i);
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Attachment', returnAll, limit);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'delete') {
                          const attachmentId = this.getNodeParameter('attachmentId', i);
                          try {
                              responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'DELETE', `/sobjects/attachment/${attachmentId}`);
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'getSummary') {
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/attachment');
                      }
                  }
                  if (resource === 'user') {
                      if (operation === 'get') {
                          const userId = this.getNodeParameter('userId', i);
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/user/${userId}`);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          try {
                              if (returnAll) {
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'User', returnAll);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                              else {
                                  const limit = this.getNodeParameter('limit', i);
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'User', returnAll, limit);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                  }
                  if (resource === 'flow') {
                      if (operation === 'invoke') {
                          const apiName = this.getNodeParameter('apiName', i);
                          const jsonParameters = this.getNodeParameter('jsonParameters', i);
                          let variables = {};
                          if (jsonParameters) {
                              variables = this.getNodeParameter('variablesJson', i);
                          }
                          else {
                              const setInputVariable = this.getNodeParameter('variablesUi', i, {});
                              if (setInputVariable.variablesValues !== undefined) {
                                  for (const inputVariableData of setInputVariable.variablesValues) {
                                      variables[inputVariableData.name] = inputVariableData.value;
                                  }
                              }
                          }
                          const body = {
                              inputs: [variables],
                          };
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', `/actions/custom/flow/${apiName}`, body);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/actions/custom/flow');
                          responseData = responseData.actions;
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              responseData = responseData.splice(0, limit);
                          }
                      }
                  }
                  if (resource === 'search') {
                      if (operation === 'query') {
                          qs.q = this.getNodeParameter('query', i);
                          responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                      }
                  }
                  if (!Array.isArray(responseData) && responseData === undefined) {
                      responseData = {
                          errors: [],
                          success: true,
                      };
                  }
                  const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                  returnData.push(...executionData);
              }
              catch (error) {
                  if (this.continueOnFail()) {
                      const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                      returnData.push(...executionErrorData);
                      continue;
                  }
                  throw error;
              }
          }
          return [returnData];
      }
  }
  exports.Salesforce = Salesforce;
  //# sourceMappingURL=Salesforce.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Salesforce credentials
  description: Documentation for Salesforce credentials. Use these credentials to authenticate Salesforce in n8n, a workflow automation platform.
  contentType: [integration, reference]
  priority: medium
  ---

  # Salesforce credentials

  You can use these credentials to authenticate the following nodes:

  - [Salesforce](/integrations/builtin/app-nodes/n8n-nodes-base.salesforce.md)
  - [Salesforce trigger](/integrations/builtin/trigger-nodes/n8n-nodes-base.salesforcetrigger.md)

  ## Supported authentication methods

  - JWT
  - OAuth2

  ## Related resources

  Refer to [Salesforce's developer documentation](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_intro.htm){:target=_blank .external-link} for more information about the service.

  ## Using JWT

  To configure this credential, you'll need a [Salesforce](https://www.salesforce.com/){:target=_blank .external-link} account and:

  - Your **Environment Type** (Production or Sandbox)
  - A **Client ID**: Generated when you create a connected app.
  - Your Salesforce **Username**
  - A **Private Key** for a self-signed digital certificate

  To set things up, first you'll create a private key and certificate, then a connected app:

  1. In n8n, select the **Environment Type** for your connection. Choose the option that best describes your environment from **Production** or **Sandbox**.
  2. Enter your Salesforce **Username**.
  1. Log in to your org in Salesforce.
  2. You'll need a private key and certificate issued by a certification authority. Use your own key/cert or use OpenSSL to create a key and a self-signed digital certificate. Refer to the Salesforce [Create a Private Key and Self-Signed Digital Certificate documentation](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth_key_and_cert.htm){:target=_blank .external-link} for instructions on creating your own key and certificate.
  3. From **Setup** in Salesforce, enter `App Manager` in the Quick Find box, then select **App Manager**.
  3. On the App Manager page, select **New Connected App**.
  4. Enter the required **Basic Info** for your connected app, including a **Name** and **Contact Email address**. Refer to Salesforce's [Configure Basic Connected App Settings](https://help.salesforce.com/s/articleView?id=sf.connected_app_create_basics.htm&type=5){:target=_blank .external-link} documentation for more information.
  5. Check the box to **Enable OAuth Settings**.
  6. For the **Callback URL**, enter `http://localhost:1717/OauthRedirect`.
  7. Check the box to **Use digital signatures**.
  8. Select **Choose File** and upload the file that contains your digital certificate, such as `server.crt`.
  9. Add these **OAuth scopes**:
  	- **Full access (full)**
  	- **Perform requests at any time (refresh_token, offline_access)**
  10. Select **Save**, then **Continue**. The **Manage Connected Apps** page should open to the app you just created.
  11. In the **API (Enable OAuth Settings)** section, select **Manage Consumer Details**.
  12. Copy the **Consumer Key** and add it to your n8n credential as the **Client ID**.
  13. Enter the contents of the private key file in n8n as **Private Key**.
  	- Use the multi-line editor in n8n.
  	- Enter the private key in standard PEM key format:
          ```
          -----BEGIN PRIVATE KEY-----
          KEY DATA GOES HERE
          -----END PRIVATE KEY-----
          ```

  These steps are what's required on the n8n side. Salesforce recommends setting refresh token policies, session policies, and OAuth policies too:

  14. In Salesforce, select **Back to Manage Connected Apps**.
  15. Select **Manage**.
  16. Select **Edit Policies**.
  17. Review the **Refresh Token Policy** field. Salesforce recommends using expire refresh token after 90 days.
  18. In the **Session Policies** section, Salesforce recommends setting **Timeout Value** to 15 minutes.
  19. In the **OAuth Policies** section, select **Admin approved users are pre-authorized for permitted users** for **Permitted Users**, and select **OK**.
  20. Select **Save**.
  21. Select **Manage Profiles**, select the profiles that are pre-authorized to use this connected app, and select **Save**.
  22. Select **Manage Permission Sets** to select the permission sets. Create permission sets if necessary.

  Refer to Salesforce's [Create a Connected App in Your Org](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth_connected_app.htm){:target=_blank .external-link} documentation for more information.


  ## Using OAuth2

  To configure this credential, you'll need a [Salesforce](https://www.salesforce.com/){:target=_blank .external-link} account.

  --8<-- "_snippets/integrations/builtin/credentials/cloud-oauth-button.md"

  Cloud and hosted users will need to select your **Environment Type**. Choose between **Production** and **Sandbox**.

  If you're [self-hosting](/hosting/index.md) n8n, you'll need to configure OAuth2 from scratch by creating a connected app:

  1. In n8n, select the **Environment Type** for your connection. Choose the option that best describes your environment from **Production** or **Sandbox**.
  2. Enter your Salesforce **Username**.
  1. Log in to your org in Salesforce.
  3. From **Setup** in Salesforce, enter `App Manager` in the Quick Find box, then select **App Manager**.
  3. On the App Manager page, select **New Connected App**.
  4. Enter the required **Basic Info** for your connected app, including a **Name** and **Contact Email address**. Refer to Salesforce's [Configure Basic Connected App Settings](https://help.salesforce.com/s/articleView?id=sf.connected_app_create_basics.htm&type=5){:target=_blank .external-link} documentation for more information.
  5. Check the box to **Enable OAuth Settings**.
  6. For the **Callback URL**, enter `http://localhost:1717/OauthRedirect`.
  9. Add these **OAuth scopes**:
  	- **Full access (full)**
  	- **Perform requests at any time (refresh_token, offline_access)**
  10. Make sure the following settings are unchecked:
  	- **Require Proof Key for Code Exchange (PKCE) Extension for Supported Authorization Flows**
  	- **Require Secret for Web Server Flow**
  	- **Require Secret for Refresh Token Flow**
  10. Select **Save**, then **Continue**. The **Manage Connected Apps** page should open to the app you just created.
  11. In the **API (Enable OAuth Settings)** section, select **Manage Consumer Details**.
  12. Copy the **Consumer Key** and add it to your n8n credential as the **Client ID**.
  13. Copy the **Consumer Secret** and add it to your n8n credential as the **Client Secret**.

  These steps are what's required on the n8n side. Salesforce recommends setting refresh token policies and session policies, too:

  14. In Salesforce, select **Back to Manage Connected Apps**.
  15. Select **Manage**.
  16. Select **Edit Policies**.
  17. Review the **Refresh Token Policy** field. Salesforce recommends using expire refresh token after 90 days.
  18. In the **Session Policies** section, Salesforce recommends setting **Timeout Value** to 15 minutes.

  Refer to Salesforce's [Create a Connected App in Your Org](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth_connected_app.htm){:target=_blank .external-link} documentation for more information.

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"69d06caf-8e69-44d0-8392-c755a7817478","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"32b12ebf531b50dae3f79dbc3dd0b29e57db18da0d4d5e6a71d74b01375d5559"}}


node_type: n8n-nodes-base.SeaTable
name: SeaTable
display_name: SeaTable
description: Consume the SeaTable API
category: Other
code_hash: 2838fa6931fb12f6c56a751f7251d2eed63f2f2160f055204f3a37ef31dd043a
documentation_url: https://docs.n8n.io/integrations/builtin/credentials/seatable
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
extracted_at: 2025-06-08 08:05:28
updated_at: 2025-06-08 08:05:28
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.SeaTable = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const GenericFunctions_1 = require("./GenericFunctions");
  const RowDescription_1 = require("./RowDescription");
  class SeaTable {
      constructor() {
          this.description = {
              displayName: 'SeaTable',
              name: 'seaTable',
              icon: 'file:seaTable.svg',
              group: ['input'],
              version: 1,
              subtitle: '={{$parameter["resource"] + ": " + $parameter["operation"]}}',
              description: 'Consume the SeaTable API',
              defaults: {
                  name: 'SeaTable',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'seaTableApi',
                      required: true,
                  },
              ],
              properties: [
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Row',
                              value: 'row',
                          },
                      ],
                      default: 'row',
                  },
                  ...RowDescription_1.rowOperations,
                  ...RowDescription_1.rowFields,
              ],
          };
          this.methods = {
              loadOptions: {
                  async getTableNames() {
                      const returnData = [];
                      const { metadata: { tables }, } = await GenericFunctions_1.seaTableApiRequest.call(this, {}, 'GET', '/dtable-server/api/v1/dtables/{{dtable_uuid}}/metadata');
                      for (const table of tables) {
                          returnData.push({
                              name: table.name,
                              value: table.name,
                          });
                      }
                      return returnData;
                  },
                  async getTableIds() {
                      const returnData = [];
                      const { metadata: { tables }, } = await GenericFunctions_1.seaTableApiRequest.call(this, {}, 'GET', '/dtable-server/api/v1/dtables/{{dtable_uuid}}/metadata');
                      for (const table of tables) {
                          returnData.push({
                              name: table.name,
                              value: table._id,
                          });
                      }
                      return returnData;
                  },
                  async getTableUpdateAbleColumns() {
                      const tableName = this.getNodeParameter('tableName');
                      const columns = await GenericFunctions_1.getTableColumns.call(this, tableName);
                      return columns
                          .filter((column) => column.editable)
                          .map((column) => ({ name: column.name, value: column.name }));
                  },
                  async getAllSortableColumns() {
                      const tableName = this.getNodeParameter('tableName');
                      const columns = await GenericFunctions_1.getTableColumns.call(this, tableName);
                      return columns
                          .filter((column) => !['file', 'image', 'url', 'collaborator', 'long-text'].includes(column.type))
                          .map((column) => ({ name: column.name, value: column.name }));
                  },
                  async getViews() {
                      const tableName = this.getNodeParameter('tableName');
                      const views = await GenericFunctions_1.getTableViews.call(this, tableName);
                      return views.map((view) => ({ name: view.name, value: view.name }));
                  },
              },
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          let responseData;
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          const body = {};
          const qs = {};
          const ctx = {};
          if (resource === 'row') {
              if (operation === 'create') {
                  const tableName = this.getNodeParameter('tableName', 0);
                  const tableColumns = await GenericFunctions_1.getTableColumns.call(this, tableName);
                  body.table_name = tableName;
                  const fieldsToSend = this.getNodeParameter('fieldsToSend', 0);
                  let rowInput = {};
                  for (let i = 0; i < items.length; i++) {
                      rowInput = {};
                      try {
                          if (fieldsToSend === 'autoMapInputData') {
                              const incomingKeys = Object.keys(items[i].json);
                              const inputDataToIgnore = (0, GenericFunctions_1.split)(this.getNodeParameter('inputsToIgnore', i, ''));
                              for (const key of incomingKeys) {
                                  if (inputDataToIgnore.includes(key))
                                      continue;
                                  rowInput[key] = items[i].json[key];
                              }
                          }
                          else {
                              const columns = this.getNodeParameter('columnsUi.columnValues', i, []);
                              for (const column of columns) {
                                  rowInput[column.columnName] = column.columnValue;
                              }
                          }
                          body.row = (0, GenericFunctions_1.rowExport)(rowInput, (0, GenericFunctions_1.updateAble)(tableColumns));
                          responseData = await GenericFunctions_1.seaTableApiRequest.call(this, ctx, 'POST', '/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/', body);
                          const { _id: insertId } = responseData;
                          if (insertId === undefined) {
                              throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'SeaTable: No identity after appending row.', { itemIndex: i });
                          }
                          const newRowInsertData = (0, GenericFunctions_1.rowMapKeyToName)(responseData, tableColumns);
                          qs.table_name = tableName;
                          qs.convert = true;
                          const newRow = await GenericFunctions_1.seaTableApiRequest.call(this, ctx, 'GET', `/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/${encodeURIComponent(insertId)}/`, body, qs);
                          if (newRow._id === undefined) {
                              throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'SeaTable: No identity for appended row.', { itemIndex: i });
                          }
                          const row = (0, GenericFunctions_1.rowFormatColumns)({ ...newRowInsertData, ...newRow }, tableColumns.map(({ name }) => name).concat(['_id', '_ctime', '_mtime']));
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(row), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionErrorData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
              else if (operation === 'get') {
                  for (let i = 0; i < items.length; i++) {
                      try {
                          const tableId = this.getNodeParameter('tableId', 0);
                          const rowId = this.getNodeParameter('rowId', i);
                          const response = (await GenericFunctions_1.seaTableApiRequest.call(this, ctx, 'GET', `/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/${rowId}`, {}, { table_id: tableId, convert: true }));
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(response), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionErrorData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
              else if (operation === 'getAll') {
                  const tableName = this.getNodeParameter('tableName', 0);
                  const tableColumns = await GenericFunctions_1.getTableColumns.call(this, tableName);
                  for (let i = 0; i < items.length; i++) {
                      try {
                          const endpoint = '/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/';
                          qs.table_name = tableName;
                          const filters = this.getNodeParameter('filters', i);
                          const options = this.getNodeParameter('options', i);
                          const returnAll = this.getNodeParameter('returnAll', 0);
                          Object.assign(qs, filters, options);
                          if (qs.convert_link_id === false) {
                              delete qs.convert_link_id;
                          }
                          if (returnAll) {
                              responseData = await GenericFunctions_1.setableApiRequestAllItems.call(this, ctx, 'rows', 'GET', endpoint, body, qs);
                          }
                          else {
                              qs.limit = this.getNodeParameter('limit', 0);
                              responseData = await GenericFunctions_1.seaTableApiRequest.call(this, ctx, 'GET', endpoint, body, qs);
                              responseData = responseData.rows;
                          }
                          const rows = responseData.map((row) => (0, GenericFunctions_1.rowFormatColumns)({ ...row }, tableColumns.map(({ name }) => name).concat(['_id', '_ctime', '_mtime'])));
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(rows), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionErrorData);
                          }
                          throw error;
                      }
                  }
              }
              else if (operation === 'delete') {
                  for (let i = 0; i < items.length; i++) {
                      try {
                          const tableName = this.getNodeParameter('tableName', 0);
                          const rowId = this.getNodeParameter('rowId', i);
                          const requestBody = {
                              table_name: tableName,
                              row_id: rowId,
                          };
                          const response = (await GenericFunctions_1.seaTableApiRequest.call(this, ctx, 'DELETE', '/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/', requestBody, qs));
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(response), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionErrorData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
              else if (operation === 'update') {
                  const tableName = this.getNodeParameter('tableName', 0);
                  const tableColumns = await GenericFunctions_1.getTableColumns.call(this, tableName);
                  body.table_name = tableName;
                  const fieldsToSend = this.getNodeParameter('fieldsToSend', 0);
                  let rowInput = {};
                  for (let i = 0; i < items.length; i++) {
                      const rowId = this.getNodeParameter('rowId', i);
                      rowInput = {};
                      try {
                          if (fieldsToSend === 'autoMapInputData') {
                              const incomingKeys = Object.keys(items[i].json);
                              const inputDataToIgnore = (0, GenericFunctions_1.split)(this.getNodeParameter('inputsToIgnore', i, ''));
                              for (const key of incomingKeys) {
                                  if (inputDataToIgnore.includes(key))
                                      continue;
                                  rowInput[key] = items[i].json[key];
                              }
                          }
                          else {
                              const columns = this.getNodeParameter('columnsUi.columnValues', i, []);
                              for (const column of columns) {
                                  rowInput[column.columnName] = column.columnValue;
                              }
                          }
                          body.row = (0, GenericFunctions_1.rowExport)(rowInput, (0, GenericFunctions_1.updateAble)(tableColumns));
                          body.table_name = tableName;
                          body.row_id = rowId;
                          responseData = await GenericFunctions_1.seaTableApiRequest.call(this, ctx, 'PUT', '/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/', body);
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ _id: rowId, ...responseData }), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionErrorData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
              else {
                  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`);
              }
          }
          return [returnData];
      }
  }
  exports.SeaTable = SeaTable;
  //# sourceMappingURL=SeaTable.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: SeaTable credentials
  description: Documentation for SeaTable credentials. Use these credentials to authenticate SeaTable in n8n, a workflow automation platform.
  contentType: [integration, reference]
  ---

  # SeaTable credentials

  You can use these credentials to authenticate the following nodes:

  - [SeaTable](/integrations/builtin/app-nodes/n8n-nodes-base.seatable.md)
  - [SeaTable Trigger](/integrations/builtin/trigger-nodes/n8n-nodes-base.seatabletrigger.md)

  ## Prerequisites

  Create a [SeaTable](https://seatable.io/en/){:target=_blank .external-link} account on either a cloud or self-hosted SeaTable server.

  ## Supported authentication methods

  - API key

  ## Related resources

  Refer to [SeaTable's API documentation](https://api.seatable.io){:target=_blank .external-link} for more information about the service.

  ## Using API key

  To configure this credential, you'll need:

  - An **Environment**: Select the environment that matches your SeaTable instance:
      - **Cloud-Hosted**
      - **Self-Hosted**
  - An **API Token (of a Base)**: Generate a **Base-Token** in SeaTable from the base options > **Advanced > API Token**.
      - Use **Read-Write** permission for your token.
      - Refer to [Creating an API token](https://seatable.io/en/docs/seatable-api/erzeugen-eines-api-tokens/){:target=_blank .external-link} for more information.
  - A **Timezone**: Select the timezone of your SeaTable server.

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"3256155b-3789-41c9-b728-ffd064a5e310","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"a5a2b4a7cf7a699b4d507648f78869eef1a5dba8af73c24e3e18dfc7137d84fd"}}


node_type: n8n-nodes-base.SecurityScorecard
name: SecurityScorecard
display_name: SecurityScorecard
description: Consume SecurityScorecard API
category: Other
code_hash: 126925cdb415faf27b54c0587590eb72f3a0a7a7be4adb9f5ffbc6121152ca14
documentation_url: https://docs.n8n.io/integrations/builtin/credentials/securityscorecard
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
extracted_at: 2025-06-08 08:05:28
updated_at: 2025-06-08 08:05:28
source_code:
  "use strict";
  var __importDefault = (this && this.__importDefault) || function (mod) {
      return (mod && mod.__esModule) ? mod : { "default": mod };
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.SecurityScorecard = void 0;
  const CompanyDescription_1 = require("./descriptions/CompanyDescription");
  const IndustryDescription_1 = require("./descriptions/IndustryDescription");
  const InviteDescription_1 = require("./descriptions/InviteDescription");
  const PortfolioDescription_1 = require("./descriptions/PortfolioDescription");
  const PortfolioCompanyDescription_1 = require("./descriptions/PortfolioCompanyDescription");
  const ReportDescription_1 = require("./descriptions/ReportDescription");
  const GenericFunctions_1 = require("./GenericFunctions");
  const moment_1 = __importDefault(require("moment"));
  class SecurityScorecard {
      constructor() {
          this.description = {
              displayName: 'SecurityScorecard',
              name: 'securityScorecard',
              icon: 'file:securityScorecard.svg',
              group: ['transform'],
              subtitle: '={{$parameter["operation"]}} : {{$parameter["resource"]}}',
              version: 1,
              description: 'Consume SecurityScorecard API',
              defaults: {
                  name: 'SecurityScorecard',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'securityScorecardApi',
                      required: true,
                  },
              ],
              properties: [
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      required: true,
                      options: [
                          {
                              name: 'Company',
                              value: 'company',
                          },
                          {
                              name: 'Industry',
                              value: 'industry',
                          },
                          {
                              name: 'Invite',
                              value: 'invite',
                          },
                          {
                              name: 'Portfolio',
                              value: 'portfolio',
                          },
                          {
                              name: 'Portfolio Company',
                              value: 'portfolioCompany',
                          },
                          {
                              name: 'Report',
                              value: 'report',
                          },
                      ],
                      default: 'company',
                  },
                  ...CompanyDescription_1.companyOperations,
                  ...CompanyDescription_1.companyFields,
                  ...IndustryDescription_1.industryOperations,
                  ...IndustryDescription_1.industryFields,
                  ...InviteDescription_1.inviteOperations,
                  ...InviteDescription_1.inviteFields,
                  ...PortfolioDescription_1.portfolioOperations,
                  ...PortfolioDescription_1.portfolioFields,
                  ...PortfolioCompanyDescription_1.portfolioCompanyOperations,
                  ...PortfolioCompanyDescription_1.portfolioCompanyFields,
                  ...ReportDescription_1.reportOperations,
                  ...ReportDescription_1.reportFields,
              ],
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          let responseData;
          const length = items.length;
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          for (let i = 0; i < length; i++) {
              if (resource === 'portfolio') {
                  if (operation === 'create') {
                      const name = this.getNodeParameter('name', i);
                      const description = this.getNodeParameter('description', i);
                      const privacy = this.getNodeParameter('privacy', i);
                      const body = {
                          name,
                          description,
                          privacy,
                      };
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'POST', 'portfolios', body);
                      returnData.push(responseData);
                  }
                  if (operation === 'delete') {
                      const portfolioId = this.getNodeParameter('portfolioId', i);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'DELETE', `portfolios/${portfolioId}`);
                      returnData.push({ success: true });
                  }
                  if (operation === 'update') {
                      const portfolioId = this.getNodeParameter('portfolioId', i);
                      const name = this.getNodeParameter('name', i);
                      const description = this.getNodeParameter('description', i);
                      const privacy = this.getNodeParameter('privacy', i);
                      const body = {
                          name,
                          description,
                          privacy,
                      };
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'PUT', `portfolios/${portfolioId}`, body);
                      returnData.push(responseData);
                  }
                  if (operation === 'getAll') {
                      const returnAll = this.getNodeParameter('returnAll', 0);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', 'portfolios');
                      responseData = responseData.entries;
                      if (!returnAll) {
                          const limit = this.getNodeParameter('limit', 0);
                          responseData = responseData.splice(0, limit);
                      }
                      returnData.push.apply(returnData, responseData);
                  }
              }
              if (resource === 'portfolioCompany') {
                  if (operation === 'add') {
                      const portfolioId = this.getNodeParameter('portfolioId', i);
                      const domain = this.getNodeParameter('domain', i);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'PUT', `portfolios/${portfolioId}/companies/${domain}`);
                      returnData.push(responseData);
                  }
                  if (operation === 'remove') {
                      const portfolioId = this.getNodeParameter('portfolioId', i);
                      const domain = this.getNodeParameter('domain', i);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'DELETE', `portfolios/${portfolioId}/companies/${domain}`);
                      returnData.push({ success: true });
                  }
                  if (operation === 'getAll') {
                      const returnAll = this.getNodeParameter('returnAll', 0);
                      const portfolioId = this.getNodeParameter('portfolioId', i);
                      const filterParams = this.getNodeParameter('filters', i);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', `portfolios/${portfolioId}/companies`, {}, filterParams);
                      responseData = responseData.entries;
                      if (!returnAll) {
                          const limit = this.getNodeParameter('limit', 0);
                          responseData = responseData.splice(0, limit);
                      }
                      returnData.push.apply(returnData, responseData);
                  }
              }
              if (resource === 'report') {
                  if (operation === 'download') {
                      const reportUrl = this.getNodeParameter('url', i);
                      const response = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', '', {}, {}, reportUrl, {
                          encoding: null,
                          resolveWithFullResponse: true,
                      });
                      let mimeType;
                      if (response.headers['content-type']) {
                          mimeType = response.headers['content-type'];
                      }
                      const newItem = {
                          json: items[i].json,
                          binary: {},
                      };
                      if (items[i].binary !== undefined && newItem.binary) {
                          Object.assign(newItem.binary, items[i].binary);
                      }
                      items[i] = newItem;
                      const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i);
                      const fileName = reportUrl.split('/').pop();
                      const data = Buffer.from(response.body, 'utf8');
                      items[i].binary[dataPropertyNameDownload] = await this.helpers.prepareBinaryData(data, fileName, mimeType);
                  }
                  if (operation === 'generate') {
                      const reportType = this.getNodeParameter('report', i);
                      let body = {};
                      if (reportType !== 'portfolio') {
                          body.scorecard_identifier = this.getNodeParameter('scorecardIdentifier', i);
                      }
                      else {
                          body.portfolio_id = this.getNodeParameter('portfolioId', i);
                      }
                      if (reportType === 'events-json') {
                          body.date = this.getNodeParameter('date', i);
                      }
                      if (['issues', 'portfolio'].indexOf(reportType) > -1) {
                          body.format = this.getNodeParameter('options.format', i) || 'pdf';
                      }
                      if (['detailed', 'summary'].indexOf(reportType) > -1) {
                          body.branding = this.getNodeParameter('branding', i);
                      }
                      if (['events-json', 'full-scorecard-json'].indexOf(reportType) > -1) {
                          body = { params: body };
                      }
                      if (reportType === 'scorecard-footprint') {
                          const options = this.getNodeParameter('options', i);
                          Object.assign(body, options);
                      }
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'POST', `reports/${reportType}`, body);
                      returnData.push(responseData);
                  }
                  if (operation === 'getAll') {
                      const returnAll = this.getNodeParameter('returnAll', 0);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', 'reports/recent');
                      responseData = responseData.entries;
                      if (!returnAll) {
                          const limit = this.getNodeParameter('limit', i);
                          responseData = responseData.splice(0, limit);
                      }
                      returnData.push.apply(returnData, responseData);
                  }
              }
              if (resource === 'invite') {
                  if (operation === 'create') {
                      const body = {
                          email: this.getNodeParameter('email', i),
                          first_name: this.getNodeParameter('firstName', i),
                          last_name: this.getNodeParameter('lastName', i),
                          message: this.getNodeParameter('message', i),
                      };
                      const additionalFields = this.getNodeParameter('additionalFields', i);
                      Object.assign(body, additionalFields);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'POST', 'invitations', body);
                      returnData.push(responseData);
                  }
              }
              if (resource === 'industry') {
                  if (operation === 'getScore') {
                      const industry = this.getNodeParameter('industry', i);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', `industries/${industry}/score`);
                      returnData.push(responseData);
                  }
                  if (operation === 'getFactor') {
                      const simple = this.getNodeParameter('simple', 0);
                      const returnAll = this.getNodeParameter('returnAll', 0);
                      const industry = this.getNodeParameter('industry', i);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', `industries/${industry}/history/factors`);
                      responseData = responseData.entries;
                      if (!returnAll) {
                          const limit = this.getNodeParameter('limit', i);
                          responseData = responseData.splice(0, limit);
                      }
                      if (simple) {
                          responseData = (0, GenericFunctions_1.simplify)(responseData);
                      }
                      returnData.push.apply(returnData, responseData);
                  }
                  if (operation === 'getFactorHistorical') {
                      const simple = this.getNodeParameter('simple', 0);
                      const returnAll = this.getNodeParameter('returnAll', i);
                      const industry = this.getNodeParameter('industry', i);
                      const options = this.getNodeParameter('options', i);
                      if (options.from) {
                          options.from = (0, moment_1.default)(options.from).format('YYYY-MM-DD');
                      }
                      if (options.to) {
                          options.to = (0, moment_1.default)(options.to).format('YYYY-MM-DD');
                      }
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', `industries/${industry}/history/factors`, {}, options);
                      responseData = responseData.entries;
                      if (!returnAll) {
                          const limit = this.getNodeParameter('limit', i);
                          responseData = responseData.splice(0, limit);
                      }
                      if (simple) {
                          responseData = (0, GenericFunctions_1.simplify)(responseData);
                      }
                      returnData.push.apply(returnData, responseData);
                  }
              }
              if (resource === 'company') {
                  if (operation === 'getScorecard') {
                      const scorecardIdentifier = this.getNodeParameter('scorecardIdentifier', i);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', `companies/${scorecardIdentifier}`);
                      returnData.push(responseData);
                  }
                  if (operation === 'getFactor') {
                      const returnAll = this.getNodeParameter('returnAll', i);
                      const scorecardIdentifier = this.getNodeParameter('scorecardIdentifier', i);
                      const filterParams = this.getNodeParameter('filters', i);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', `companies/${scorecardIdentifier}/factors`, {}, filterParams);
                      responseData = responseData.entries;
                      if (!returnAll) {
                          const limit = this.getNodeParameter('limit', i);
                          responseData = responseData.splice(0, limit);
                      }
                      returnData.push.apply(returnData, responseData);
                  }
                  if (operation === 'getFactorHistorical') {
                      const simple = this.getNodeParameter('simple', 0);
                      const returnAll = this.getNodeParameter('returnAll', i);
                      const scorecardIdentifier = this.getNodeParameter('scorecardIdentifier', i);
                      const options = this.getNodeParameter('options', i);
                      if (options.date_from) {
                          options.date_from = (0, moment_1.default)(options.date_from).format('YYYY-MM-DD');
                      }
                      if (options.date_to) {
                          options.date_to = (0, moment_1.default)(options.date_to).format('YYYY-MM-DD');
                      }
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', `companies/${scorecardIdentifier}/history/factors/score`, {}, options);
                      responseData = responseData.entries;
                      if (!returnAll) {
                          const limit = this.getNodeParameter('limit', i);
                          responseData = responseData.splice(0, limit);
                      }
                      if (simple) {
                          responseData = (0, GenericFunctions_1.simplify)(responseData);
                      }
                      returnData.push.apply(returnData, responseData);
                  }
                  if (operation === 'getHistoricalScore') {
                      const simple = this.getNodeParameter('simple', 0);
                      const returnAll = this.getNodeParameter('returnAll', i);
                      const scorecardIdentifier = this.getNodeParameter('scorecardIdentifier', i);
                      const options = this.getNodeParameter('options', i);
                      if (options.date_from) {
                          options.from = (0, moment_1.default)(options.date_from).format('YYYY-MM-DD');
                          delete options.date_from;
                      }
                      if (options.date_to) {
                          options.to = (0, moment_1.default)(options.date_to).format('YYYY-MM-DD');
                          delete options.date_to;
                      }
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', `companies/${scorecardIdentifier}/history/factors/score`, {}, options);
                      responseData = responseData.entries;
                      if (!returnAll) {
                          const limit = this.getNodeParameter('limit', i);
                          responseData = responseData.splice(0, limit);
                      }
                      if (simple) {
                          responseData = (0, GenericFunctions_1.simplify)(responseData);
                      }
                      returnData.push.apply(returnData, responseData);
                  }
                  if (operation === 'getScorePlan') {
                      const returnAll = this.getNodeParameter('returnAll', i);
                      const scorecardIdentifier = this.getNodeParameter('scorecardIdentifier', i);
                      const targetScore = this.getNodeParameter('score', i);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', `companies/${scorecardIdentifier}/score-plans/by-target/${targetScore}`);
                      responseData = responseData.entries;
                      if (!returnAll) {
                          const limit = this.getNodeParameter('limit', i);
                          responseData = responseData.splice(0, limit);
                      }
                      returnData.push.apply(returnData, responseData);
                  }
              }
          }
          if (resource === 'report' && operation === 'download') {
              return [items];
          }
          return [this.helpers.returnJsonArray(returnData)];
      }
  }
  exports.SecurityScorecard = SecurityScorecard;
  //# sourceMappingURL=SecurityScorecard.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: SecurityScorecard credentials
  description: Documentation for SecurityScorecard credentials. Use these credentials to authenticate SecurityScorecard in n8n, a workflow automation platform.
  contentType: [integration, reference]
  ---

  # SecurityScorecard credentials

  You can use these credentials to authenticate the following nodes:

  - [SecurityScorecard](/integrations/builtin/app-nodes/n8n-nodes-base.securityscorecard.md)


  ## Prerequisites

  Create a [SecurityScorecard](https://securityscorecard.com/){:target=_blank .external-link} account.

  ## Supported authentication methods

  - API key

  ## Related resources

  Refer to [SecurityScorecard's Developer documentation](https://securityscorecard.readme.io/docs/integrate-ratings-platform-services){:target=_blank .external-link} and [API documentation](https://securityscorecard.readme.io/reference/introduction){:target=_blank .external-link} for more information about the service.

  ## Using API key

  To configure this credential, you'll need:

  - An **API Key**: Generate an API key in one of two ways:
      * As a user in [**My Settings > API**](https://platform.securityscorecard.io/#/my-settings/api){:target=_blank .external-link}. Refer to [Get an API key](https://securityscorecard.readme.io/docs/getting-started#step-1-get-an-api-key){:target=_blank .external-link} for more information.
      * As a bot user: View the bot user and select **create token**. Refer to [Authenticate with a bot user](https://securityscorecard.readme.io/docs/authentication#){:target=_blank .external-link} for more information.

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"b6cf8422-bbc0-4f01-b464-65404ff2f09d","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"5057415944b754bdf44ee92835486698b82e8a326e5f14cc03ecdf41f8684cd3"}}


node_type: n8n-nodes-base.Segment
name: Segment
display_name: Segment
description: Consume Segment API
category: Other
code_hash: 9fc9d8949d7a2d9b8ae94a10b699705756e1f9f2cb2e6a0feeff301b5108b19d
documentation_url: https://docs.n8n.io/integrations/builtin/credentials/segment
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
extracted_at: 2025-06-08 08:05:29
updated_at: 2025-06-08 08:05:29
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.Segment = void 0;
  const GenericFunctions_1 = require("./GenericFunctions");
  const GroupDescription_1 = require("./GroupDescription");
  const IdentifyDescription_1 = require("./IdentifyDescription");
  const TrackDescription_1 = require("./TrackDescription");
  const uuid_1 = require("uuid");
  class Segment {
      constructor() {
          this.description = {
              displayName: 'Segment',
              name: 'segment',
              icon: 'file:segment.svg',
              group: ['output'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ":" + $parameter["resource"]}}',
              description: 'Consume Segment API',
              defaults: {
                  name: 'Segment',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'segmentApi',
                      required: true,
                  },
              ],
              properties: [
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Group',
                              value: 'group',
                              description: 'Group lets you associate an identified user with a group',
                          },
                          {
                              name: 'Identify',
                              value: 'identify',
                              description: 'Identify lets you tie a user to their actions',
                          },
                          {
                              name: 'Track',
                              value: 'track',
                              description: 'Track lets you record events',
                          },
                      ],
                      default: 'identify',
                  },
                  ...GroupDescription_1.groupOperations,
                  ...GroupDescription_1.groupFields,
                  ...IdentifyDescription_1.identifyOperations,
                  ...TrackDescription_1.trackOperations,
                  ...IdentifyDescription_1.identifyFields,
                  ...TrackDescription_1.trackFields,
              ],
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          const length = items.length;
          let responseData;
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          for (let i = 0; i < length; i++) {
              try {
                  if (resource === 'group') {
                      if (operation === 'add') {
                          const userId = this.getNodeParameter('userId', i);
                          const groupId = this.getNodeParameter('groupId', i);
                          const traits = this.getNodeParameter('traits', i)
                              .traitsUi;
                          const context = this.getNodeParameter('context', i)
                              .contextUi;
                          const integrations = this.getNodeParameter('integrations', i)
                              .integrationsUi;
                          const body = {
                              groupId,
                              traits: {
                                  company: {},
                                  address: {},
                              },
                              context: {
                                  app: {},
                                  campaign: {},
                                  device: {},
                              },
                              integrations: {},
                          };
                          if (userId) {
                              body.userId = userId;
                          }
                          else {
                              body.anonymousId = (0, uuid_1.v4)();
                          }
                          if (traits) {
                              if (traits && traits.length !== 0) {
                                  for (const trait of traits) {
                                      body.traits[trait.key] = trait.value;
                                  }
                              }
                          }
                          if (context) {
                              if (context.active) {
                                  body.context.active = context.active;
                              }
                              if (context.ip) {
                                  body.context.ip = context.ip;
                              }
                              if (context.locate) {
                                  body.context.locate = context.locate;
                              }
                              if (context.page) {
                                  body.context.page = context.page;
                              }
                              if (context.timezone) {
                                  body.context.timezone = context.timezone;
                              }
                              if (context.timezone) {
                                  body.context.timezone = context.timezone;
                              }
                              if (context.app) {
                                  const app = context.app.appUi;
                                  if (app) {
                                      if (app.name) {
                                          body.context.app.name = app.name;
                                      }
                                      if (app.version) {
                                          body.context.app.version = app.version;
                                      }
                                      if (app.build) {
                                          body.context.app.build = app.build;
                                      }
                                  }
                              }
                              if (context.campaign) {
                                  const campaign = context.campaign.campaignUi;
                                  if (campaign) {
                                      if (campaign.name) {
                                          body.context.campaign.name = campaign.name;
                                      }
                                      if (campaign.source) {
                                          body.context.campaign.source = campaign.source;
                                      }
                                      if (campaign.medium) {
                                          body.context.campaign.medium = campaign.medium;
                                      }
                                      if (campaign.term) {
                                          body.context.campaign.term = campaign.term;
                                      }
                                      if (campaign.content) {
                                          body.context.campaign.content = campaign.content;
                                      }
                                  }
                              }
                              if (context.device) {
                                  const device = context.device.deviceUi;
                                  if (device) {
                                      if (device.id) {
                                          body.context.device.id = device.id;
                                      }
                                      if (device.manufacturer) {
                                          body.context.device.manufacturer = device.manufacturer;
                                      }
                                      if (device.model) {
                                          body.context.device.model = device.model;
                                      }
                                      if (device.type) {
                                          body.context.device.type = device.type;
                                      }
                                      if (device.version) {
                                          body.context.device.version = device.version;
                                      }
                                  }
                              }
                          }
                          if (integrations) {
                              if (integrations.all) {
                                  body.integrations.all = integrations.all;
                              }
                              if (integrations.salesforce) {
                                  body.integrations.salesforce = integrations.salesforce;
                              }
                          }
                          responseData = await GenericFunctions_1.segmentApiRequest.call(this, 'POST', '/group', body);
                      }
                  }
                  if (resource === 'identify') {
                      if (operation === 'create') {
                          const userId = this.getNodeParameter('userId', i);
                          const context = this.getNodeParameter('context', i)
                              .contextUi;
                          const traits = this.getNodeParameter('traits', i)
                              .traitsUi;
                          const integrations = this.getNodeParameter('integrations', i)
                              .integrationsUi;
                          const body = {
                              context: {
                                  app: {},
                                  campaign: {},
                                  device: {},
                              },
                              traits: {},
                              integrations: {},
                          };
                          if (userId) {
                              body.userId = userId;
                          }
                          else {
                              body.anonymousId = (0, uuid_1.v4)();
                          }
                          if (context) {
                              if (context.active) {
                                  body.context.active = context.active;
                              }
                              if (context.ip) {
                                  body.context.ip = context.ip;
                              }
                              if (context.locate) {
                                  body.context.locate = context.locate;
                              }
                              if (context.page) {
                                  body.context.page = context.page;
                              }
                              if (context.timezone) {
                                  body.context.timezone = context.timezone;
                              }
                              if (context.timezone) {
                                  body.context.timezone = context.timezone;
                              }
                              if (context.app) {
                                  const app = context.app.appUi;
                                  if (app) {
                                      if (app.name) {
                                          body.context.app.name = app.name;
                                      }
                                      if (app.version) {
                                          body.context.app.version = app.version;
                                      }
                                      if (app.build) {
                                          body.context.app.build = app.build;
                                      }
                                  }
                              }
                              if (context.campaign) {
                                  const campaign = context.campaign.campaignUi;
                                  if (campaign) {
                                      if (campaign.name) {
                                          body.context.campaign.name = campaign.name;
                                      }
                                      if (campaign.source) {
                                          body.context.campaign.source = campaign.source;
                                      }
                                      if (campaign.medium) {
                                          body.context.campaign.medium = campaign.medium;
                                      }
                                      if (campaign.term) {
                                          body.context.campaign.term = campaign.term;
                                      }
                                      if (campaign.content) {
                                          body.context.campaign.content = campaign.content;
                                      }
                                  }
                              }
                              if (context.device) {
                                  const device = context.device.deviceUi;
                                  if (device) {
                                      if (device.id) {
                                          body.context.device.id = device.id;
                                      }
                                      if (device.manufacturer) {
                                          body.context.device.manufacturer = device.manufacturer;
                                      }
                                      if (device.model) {
                                          body.context.device.model = device.model;
                                      }
                                      if (device.type) {
                                          body.context.device.type = device.type;
                                      }
                                      if (device.version) {
                                          body.context.device.version = device.version;
                                      }
                                  }
                              }
                          }
                          if (integrations) {
                              if (integrations.all) {
                                  body.integrations.all = integrations.all;
                              }
                              if (integrations.salesforce) {
                                  body.integrations.salesforce = integrations.salesforce;
                              }
                          }
                          if (traits) {
                              if (traits && traits.length !== 0) {
                                  for (const trait of traits) {
                                      body.traits[trait.key] = trait.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.segmentApiRequest.call(this, 'POST', '/identify', body);
                      }
                  }
                  if (resource === 'track') {
                      if (operation === 'event') {
                          const userId = this.getNodeParameter('userId', i);
                          const event = this.getNodeParameter('event', i);
                          const context = this.getNodeParameter('context', i)
                              .contextUi;
                          const integrations = this.getNodeParameter('integrations', i)
                              .integrationsUi;
                          const properties = this.getNodeParameter('properties', i)
                              .propertiesUi;
                          const body = {
                              event,
                              traits: {},
                              context: {
                                  app: {},
                                  campaign: {},
                                  device: {},
                              },
                              integrations: {},
                              properties: {},
                          };
                          if (userId) {
                              body.userId = userId;
                          }
                          else {
                              body.anonymousId = (0, uuid_1.v4)();
                          }
                          if (context) {
                              if (context.active) {
                                  body.context.active = context.active;
                              }
                              if (context.ip) {
                                  body.context.ip = context.ip;
                              }
                              if (context.locate) {
                                  body.context.locate = context.locate;
                              }
                              if (context.page) {
                                  body.context.page = context.page;
                              }
                              if (context.timezone) {
                                  body.context.timezone = context.timezone;
                              }
                              if (context.timezone) {
                                  body.context.timezone = context.timezone;
                              }
                              if (context.app) {
                                  const app = context.app.appUi;
                                  if (app) {
                                      if (app.name) {
                                          body.context.app.name = app.name;
                                      }
                                      if (app.version) {
                                          body.context.app.version = app.version;
                                      }
                                      if (app.build) {
                                          body.context.app.build = app.build;
                                      }
                                  }
                              }
                              if (context.campaign) {
                                  const campaign = context.campaign.campaignUi;
                                  if (campaign) {
                                      if (campaign.name) {
                                          body.context.campaign.name = campaign.name;
                                      }
                                      if (campaign.source) {
                                          body.context.campaign.source = campaign.source;
                                      }
                                      if (campaign.medium) {
                                          body.context.campaign.medium = campaign.medium;
                                      }
                                      if (campaign.term) {
                                          body.context.campaign.term = campaign.term;
                                      }
                                      if (campaign.content) {
                                          body.context.campaign.content = campaign.content;
                                      }
                                  }
                              }
                              if (context.device) {
                                  const device = context.device.deviceUi;
                                  if (device) {
                                      if (device.id) {
                                          body.context.device.id = device.id;
                                      }
                                      if (device.manufacturer) {
                                          body.context.device.manufacturer = device.manufacturer;
                                      }
                                      if (device.model) {
                                          body.context.device.model = device.model;
                                      }
                                      if (device.type) {
                                          body.context.device.type = device.type;
                                      }
                                      if (device.version) {
                                          body.context.device.version = device.version;
                                      }
                                  }
                              }
                          }
                          if (integrations) {
                              if (integrations.all) {
                                  body.integrations.all = integrations.all;
                              }
                              if (integrations.salesforce) {
                                  body.integrations.salesforce = integrations.salesforce;
                              }
                          }
                          if (properties) {
                              if (properties && properties.length !== 0) {
                                  for (const property of properties) {
                                      body.properties[property.key] = property.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.segmentApiRequest.call(this, 'POST', '/track', body);
                      }
                      if (operation === 'page') {
                          const userId = this.getNodeParameter('userId', i);
                          const name = this.getNodeParameter('name', i);
                          const context = this.getNodeParameter('context', i)
                              .contextUi;
                          const integrations = this.getNodeParameter('integrations', i)
                              .integrationsUi;
                          const properties = this.getNodeParameter('properties', i)
                              .propertiesUi;
                          const body = {
                              name,
                              traits: {},
                              context: {
                                  app: {},
                                  campaign: {},
                                  device: {},
                              },
                              integrations: {},
                              properties: {},
                          };
                          if (userId) {
                              body.userId = userId;
                          }
                          else {
                              body.anonymousId = (0, uuid_1.v4)();
                          }
                          if (context) {
                              if (context.active) {
                                  body.context.active = context.active;
                              }
                              if (context.ip) {
                                  body.context.ip = context.ip;
                              }
                              if (context.locate) {
                                  body.context.locate = context.locate;
                              }
                              if (context.page) {
                                  body.context.page = context.page;
                              }
                              if (context.timezone) {
                                  body.context.timezone = context.timezone;
                              }
                              if (context.timezone) {
                                  body.context.timezone = context.timezone;
                              }
                              if (context.app) {
                                  const app = context.app.appUi;
                                  if (app) {
                                      if (app.name) {
                                          body.context.app.name = app.name;
                                      }
                                      if (app.version) {
                                          body.context.app.version = app.version;
                                      }
                                      if (app.build) {
                                          body.context.app.build = app.build;
                                      }
                                  }
                              }
                              if (context.campaign) {
                                  const campaign = context.campaign.campaignUi;
                                  if (campaign) {
                                      if (campaign.name) {
                                          body.context.campaign.name = campaign.name;
                                      }
                                      if (campaign.source) {
                                          body.context.campaign.source = campaign.source;
                                      }
                                      if (campaign.medium) {
                                          body.context.campaign.medium = campaign.medium;
                                      }
                                      if (campaign.term) {
                                          body.context.campaign.term = campaign.term;
                                      }
                                      if (campaign.content) {
                                          body.context.campaign.content = campaign.content;
                                      }
                                  }
                              }
                              if (context.device) {
                                  const device = context.device.deviceUi;
                                  if (device) {
                                      if (device.id) {
                                          body.context.device.id = device.id;
                                      }
                                      if (device.manufacturer) {
                                          body.context.device.manufacturer = device.manufacturer;
                                      }
                                      if (device.model) {
                                          body.context.device.model = device.model;
                                      }
                                      if (device.type) {
                                          body.context.device.type = device.type;
                                      }
                                      if (device.version) {
                                          body.context.device.version = device.version;
                                      }
                                  }
                              }
                          }
                          if (integrations) {
                              if (integrations.all) {
                                  body.integrations.all = integrations.all;
                              }
                              if (integrations.salesforce) {
                                  body.integrations.salesforce = integrations.salesforce;
                              }
                          }
                          if (properties) {
                              if (properties && properties.length !== 0) {
                                  for (const property of properties) {
                                      body.properties[property.key] = property.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.segmentApiRequest.call(this, 'POST', '/page', body);
                      }
                  }
              }
              catch (error) {
                  if (this.continueOnFail()) {
                      returnData.push({ error: error.message });
                      continue;
                  }
                  throw error;
              }
              if (Array.isArray(responseData)) {
                  returnData.push.apply(returnData, responseData);
              }
              else {
                  returnData.push(responseData);
              }
          }
          return [this.helpers.returnJsonArray(returnData)];
      }
  }
  exports.Segment = Segment;
  //# sourceMappingURL=Segment.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Segment credentials
  description: Documentation for Segment credentials. Use these credentials to authenticate Segment in n8n, a workflow automation platform.
  contentType: [integration, reference]
  ---

  # Segment credentials

  You can use these credentials to authenticate the following nodes:

  - [Segment](/integrations/builtin/app-nodes/n8n-nodes-base.segment.md)

  ## Prerequisites

  Create a [Segment](https://segment.com/){:target=_blank .external-link} account.

  ## Supported authentication methods

  - API key

  ## Related resources

  Refer to [Segment's Sources documentation](https://segment.com/docs/connections/sources/){:target=_blank .external-link} for more information about the service.

  ## Using API key

  To configure this credential, you'll need:

  - A **Write Key**: To get a Write Key, go to **Sources > Add Source**. Add a **Node.js** source and copy that write key to add to your n8n credential.

  Refer to [Locate your Write Key](https://segment.com/docs/connections/find-writekey/){:target=_blank .external-link} for more information.

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"10adc4af-ff3f-402c-9d42-a29067ed075a","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"93be4e2c44ac0243ae80229c3918db244ff56a0138e03ed849f940ea7298245e"}}


node_type: n8n-nodes-base.S3
name: S3
display_name: S3
description: Sends data to any S3-compatible service
category: Other
code_hash: 80c075ea70231b2247f5c6f3da95d4769d94dc14792e809bb2a267a14d97e036
documentation_url: https://docs.n8n.io/integrations/builtin/credentials/s3
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
extracted_at: 2025-06-08 08:05:29
updated_at: 2025-06-08 08:05:29
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.S3 = void 0;
  const change_case_1 = require("change-case");
  const crypto_1 = require("crypto");
  const xml2js_1 = require("xml2js");
  const n8n_workflow_1 = require("n8n-workflow");
  const BucketDescription_1 = require("../Aws/S3/V1/BucketDescription");
  const FolderDescription_1 = require("../Aws/S3/V1/FolderDescription");
  const FileDescription_1 = require("../Aws/S3/V1/FileDescription");
  const GenericFunctions_1 = require("./GenericFunctions");
  class S3 {
      constructor() {
          this.description = {
              displayName: 'S3',
              name: 's3',
              icon: 'file:s3.png',
              group: ['output'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
              description: 'Sends data to any S3-compatible service',
              defaults: {
                  name: 'S3',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 's3',
                      required: true,
                  },
              ],
              properties: [
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Bucket',
                              value: 'bucket',
                          },
                          {
                              name: 'File',
                              value: 'file',
                          },
                          {
                              name: 'Folder',
                              value: 'folder',
                          },
                      ],
                      default: 'file',
                  },
                  ...BucketDescription_1.bucketOperations,
                  ...BucketDescription_1.bucketFields,
                  ...FolderDescription_1.folderOperations,
                  ...FolderDescription_1.folderFields,
                  ...FileDescription_1.fileOperations,
                  ...FileDescription_1.fileFields,
              ],
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          const qs = {};
          let responseData;
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          for (let i = 0; i < items.length; i++) {
              try {
                  const headers = {};
                  if (resource === 'bucket') {
                      if (operation === 'create') {
                          let credentials;
                          try {
                              credentials = await this.getCredentials('s3');
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                          const name = this.getNodeParameter('name', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (additionalFields.acl) {
                              headers['x-amz-acl'] = (0, change_case_1.paramCase)(additionalFields.acl);
                          }
                          if (additionalFields.bucketObjectLockEnabled) {
                              headers['x-amz-bucket-object-lock-enabled'] =
                                  additionalFields.bucketObjectLockEnabled;
                          }
                          if (additionalFields.grantFullControl) {
                              headers['x-amz-grant-full-control'] = '';
                          }
                          if (additionalFields.grantRead) {
                              headers['x-amz-grant-read'] = '';
                          }
                          if (additionalFields.grantReadAcp) {
                              headers['x-amz-grant-read-acp'] = '';
                          }
                          if (additionalFields.grantWrite) {
                              headers['x-amz-grant-write'] = '';
                          }
                          if (additionalFields.grantWriteAcp) {
                              headers['x-amz-grant-write-acp'] = '';
                          }
                          let region = credentials.region;
                          if (additionalFields.region) {
                              region = additionalFields.region;
                          }
                          const body = {
                              CreateBucketConfiguration: {
                                  $: {
                                      xmlns: 'http://s3.amazonaws.com/doc/2006-03-01/',
                                  },
                              },
                          };
                          let data = '';
                          if (region !== 'us-east-1') {
                              body.CreateBucketConfiguration.LocationConstraint = [region];
                              const builder = new xml2js_1.Builder();
                              data = builder.buildObject(body);
                          }
                          responseData = await GenericFunctions_1.s3ApiRequestSOAP.call(this, `${name}`, 'PUT', '', data, qs, headers);
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ success: true }), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', 0);
                          if (returnAll) {
                              responseData = await GenericFunctions_1.s3ApiRequestSOAPAllItems.call(this, 'ListAllMyBucketsResult.Buckets.Bucket', '', 'GET', '');
                          }
                          else {
                              qs.limit = this.getNodeParameter('limit', 0);
                              responseData = await GenericFunctions_1.s3ApiRequestSOAPAllItems.call(this, 'ListAllMyBucketsResult.Buckets.Bucket', '', 'GET', '', '', qs);
                              responseData = responseData.slice(0, qs.limit);
                          }
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      if (operation === 'search') {
                          const bucketName = this.getNodeParameter('bucketName', i);
                          const returnAll = this.getNodeParameter('returnAll', 0);
                          const additionalFields = this.getNodeParameter('additionalFields', 0);
                          if (additionalFields.prefix) {
                              qs.prefix = additionalFields.prefix;
                          }
                          if (additionalFields.encodingType) {
                              qs['encoding-type'] = additionalFields.encodingType;
                          }
                          if (additionalFields.delmiter) {
                              qs.delimiter = additionalFields.delmiter;
                          }
                          if (additionalFields.fetchOwner) {
                              qs['fetch-owner'] = additionalFields.fetchOwner;
                          }
                          if (additionalFields.startAfter) {
                              qs['start-after'] = additionalFields.startAfter;
                          }
                          if (additionalFields.requesterPays) {
                              qs['x-amz-request-payer'] = 'requester';
                          }
                          qs['list-type'] = 2;
                          responseData = await GenericFunctions_1.s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', {
                              location: '',
                          });
                          const region = responseData.LocationConstraint._;
                          if (returnAll) {
                              responseData = await GenericFunctions_1.s3ApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', bucketName, 'GET', '', '', qs, {}, {}, region);
                          }
                          else {
                              qs['max-keys'] = this.getNodeParameter('limit', 0);
                              responseData = await GenericFunctions_1.s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', qs, {}, {}, region);
                              responseData = responseData.ListBucketResult.Contents;
                          }
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                  }
                  if (resource === 'folder') {
                      if (operation === 'create') {
                          const bucketName = this.getNodeParameter('bucketName', i);
                          const folderName = this.getNodeParameter('folderName', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          let path = `/${folderName}/`;
                          if (additionalFields.requesterPays) {
                              headers['x-amz-request-payer'] = 'requester';
                          }
                          if (additionalFields.parentFolderKey) {
                              path = `/${additionalFields.parentFolderKey}${folderName}/`;
                          }
                          if (additionalFields.storageClass) {
                              headers['x-amz-storage-class'] = (0, change_case_1.snakeCase)(additionalFields.storageClass).toUpperCase();
                          }
                          responseData = await GenericFunctions_1.s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', {
                              location: '',
                          });
                          const region = responseData.LocationConstraint._;
                          responseData = await GenericFunctions_1.s3ApiRequestSOAP.call(this, bucketName, 'PUT', path, '', qs, headers, {}, region);
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ success: true }), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      if (operation === 'delete') {
                          const bucketName = this.getNodeParameter('bucketName', i);
                          const folderKey = this.getNodeParameter('folderKey', i);
                          responseData = await GenericFunctions_1.s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', {
                              location: '',
                          });
                          const region = responseData.LocationConstraint._;
                          responseData = await GenericFunctions_1.s3ApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', bucketName, 'GET', '/', '', { 'list-type': 2, prefix: folderKey }, {}, {}, region);
                          if (responseData.length === 0) {
                              responseData = await GenericFunctions_1.s3ApiRequestSOAP.call(this, bucketName, 'DELETE', `/${folderKey}`, '', qs, {}, {}, region);
                              responseData = { deleted: [{ Key: folderKey }] };
                          }
                          else {
                              const body = {
                                  Delete: {
                                      $: {
                                          xmlns: 'http://s3.amazonaws.com/doc/2006-03-01/',
                                      },
                                      Object: [],
                                  },
                              };
                              for (const childObject of responseData) {
                                  body.Delete.Object.push({
                                      Key: childObject.Key,
                                  });
                              }
                              const builder = new xml2js_1.Builder();
                              const data = builder.buildObject(body);
                              headers['Content-MD5'] = (0, crypto_1.createHash)('md5').update(data).digest('base64');
                              headers['Content-Type'] = 'application/xml';
                              responseData = await GenericFunctions_1.s3ApiRequestSOAP.call(this, bucketName, 'POST', '/', data, { delete: '' }, headers, {}, region);
                              responseData = { deleted: responseData.DeleteResult.Deleted };
                          }
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      if (operation === 'getAll') {
                          const bucketName = this.getNodeParameter('bucketName', i);
                          const returnAll = this.getNodeParameter('returnAll', 0);
                          const options = this.getNodeParameter('options', 0);
                          if (options.folderKey) {
                              qs.prefix = options.folderKey;
                          }
                          if (options.fetchOwner) {
                              qs['fetch-owner'] = options.fetchOwner;
                          }
                          qs['list-type'] = 2;
                          responseData = await GenericFunctions_1.s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', {
                              location: '',
                          });
                          const region = responseData.LocationConstraint._;
                          if (returnAll) {
                              responseData = await GenericFunctions_1.s3ApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', bucketName, 'GET', '', '', qs, {}, {}, region);
                          }
                          else {
                              qs.limit = this.getNodeParameter('limit', 0);
                              responseData = await GenericFunctions_1.s3ApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', bucketName, 'GET', '', '', qs, {}, {}, region);
                          }
                          if (Array.isArray(responseData)) {
                              responseData = responseData.filter((e) => e.Key.endsWith('/') && e.Size === '0' && e.Key !== options.folderKey);
                              if (qs.limit) {
                                  responseData = responseData.splice(0, qs.limit);
                              }
                          }
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                  }
                  if (resource === 'file') {
                      if (operation === 'copy') {
                          const sourcePath = this.getNodeParameter('sourcePath', i);
                          const destinationPath = this.getNodeParameter('destinationPath', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          headers['x-amz-copy-source'] = sourcePath;
                          if (additionalFields.requesterPays) {
                              headers['x-amz-request-payer'] = 'requester';
                          }
                          if (additionalFields.storageClass) {
                              headers['x-amz-storage-class'] = (0, change_case_1.snakeCase)(additionalFields.storageClass).toUpperCase();
                          }
                          if (additionalFields.acl) {
                              headers['x-amz-acl'] = (0, change_case_1.paramCase)(additionalFields.acl);
                          }
                          if (additionalFields.grantFullControl) {
                              headers['x-amz-grant-full-control'] = '';
                          }
                          if (additionalFields.grantRead) {
                              headers['x-amz-grant-read'] = '';
                          }
                          if (additionalFields.grantReadAcp) {
                              headers['x-amz-grant-read-acp'] = '';
                          }
                          if (additionalFields.grantWriteAcp) {
                              headers['x-amz-grant-write-acp'] = '';
                          }
                          if (additionalFields.lockLegalHold) {
                              headers['x-amz-object-lock-legal-hold'] = additionalFields.lockLegalHold
                                  ? 'ON'
                                  : 'OFF';
                          }
                          if (additionalFields.lockMode) {
                              headers['x-amz-object-lock-mode'] = additionalFields.lockMode.toUpperCase();
                          }
                          if (additionalFields.lockRetainUntilDate) {
                              headers['x-amz-object-lock-retain-until-date'] =
                                  additionalFields.lockRetainUntilDate;
                          }
                          if (additionalFields.serverSideEncryption) {
                              headers['x-amz-server-side-encryption'] =
                                  additionalFields.serverSideEncryption;
                          }
                          if (additionalFields.encryptionAwsKmsKeyId) {
                              headers['x-amz-server-side-encryption-aws-kms-key-id'] =
                                  additionalFields.encryptionAwsKmsKeyId;
                          }
                          if (additionalFields.serverSideEncryptionContext) {
                              headers['x-amz-server-side-encryption-context'] =
                                  additionalFields.serverSideEncryptionContext;
                          }
                          if (additionalFields.serversideEncryptionCustomerAlgorithm) {
                              headers['x-amz-server-side-encryption-customer-algorithm'] =
                                  additionalFields.serversideEncryptionCustomerAlgorithm;
                          }
                          if (additionalFields.serversideEncryptionCustomerKey) {
                              headers['x-amz-server-side-encryption-customer-key'] =
                                  additionalFields.serversideEncryptionCustomerKey;
                          }
                          if (additionalFields.serversideEncryptionCustomerKeyMD5) {
                              headers['x-amz-server-side-encryption-customer-key-MD5'] =
                                  additionalFields.serversideEncryptionCustomerKeyMD5;
                          }
                          if (additionalFields.taggingDirective) {
                              headers['x-amz-tagging-directive'] = additionalFields.taggingDirective.toUpperCase();
                          }
                          if (additionalFields.metadataDirective) {
                              headers['x-amz-metadata-directive'] = additionalFields.metadataDirective.toUpperCase();
                          }
                          const destinationParts = destinationPath.split('/');
                          const bucketName = destinationParts[1];
                          const destination = `/${destinationParts.slice(2, destinationParts.length).join('/')}`;
                          responseData = await GenericFunctions_1.s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', {
                              location: '',
                          });
                          const region = responseData.LocationConstraint._;
                          responseData = await GenericFunctions_1.s3ApiRequestSOAP.call(this, bucketName, 'PUT', destination, '', qs, headers, {}, region);
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData.CopyObjectResult), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      if (operation === 'download') {
                          const bucketName = this.getNodeParameter('bucketName', i);
                          const fileKey = this.getNodeParameter('fileKey', i);
                          const fileName = fileKey.split('/')[fileKey.split('/').length - 1];
                          if (fileKey.substring(fileKey.length - 1) === '/') {
                              throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Downloding a whole directory is not yet supported, please provide a file key');
                          }
                          let region = await GenericFunctions_1.s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', {
                              location: '',
                          });
                          region = region.LocationConstraint._;
                          const response = await GenericFunctions_1.s3ApiRequestREST.call(this, bucketName, 'GET', `/${fileKey}`, '', qs, {}, { encoding: null, resolveWithFullResponse: true }, region);
                          let mimeType;
                          if (response.headers['content-type']) {
                              mimeType = response.headers['content-type'];
                          }
                          const newItem = {
                              json: items[i].json,
                              binary: {},
                          };
                          if (items[i].binary !== undefined) {
                              Object.assign(newItem.binary, items[i].binary);
                          }
                          items[i] = newItem;
                          const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i);
                          const data = Buffer.from(response.body, 'utf8');
                          items[i].binary[dataPropertyNameDownload] = await this.helpers.prepareBinaryData(data, fileName, mimeType);
                      }
                      if (operation === 'delete') {
                          const bucketName = this.getNodeParameter('bucketName', i);
                          const fileKey = this.getNodeParameter('fileKey', i);
                          const options = this.getNodeParameter('options', i);
                          if (options.versionId) {
                              qs.versionId = options.versionId;
                          }
                          responseData = await GenericFunctions_1.s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', {
                              location: '',
                          });
                          const region = responseData.LocationConstraint._;
                          responseData = await GenericFunctions_1.s3ApiRequestSOAP.call(this, bucketName, 'DELETE', `/${fileKey}`, '', qs, {}, {}, region);
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ success: true }), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      if (operation === 'getAll') {
                          const bucketName = this.getNodeParameter('bucketName', i);
                          const returnAll = this.getNodeParameter('returnAll', 0);
                          const options = this.getNodeParameter('options', 0);
                          if (options.folderKey) {
                              qs.prefix = options.folderKey;
                          }
                          if (options.fetchOwner) {
                              qs['fetch-owner'] = options.fetchOwner;
                          }
                          qs.delimiter = '/';
                          qs['list-type'] = 2;
                          responseData = await GenericFunctions_1.s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', {
                              location: '',
                          });
                          const region = responseData.LocationConstraint._;
                          if (returnAll) {
                              responseData = await GenericFunctions_1.s3ApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', bucketName, 'GET', '', '', qs, {}, {}, region);
                          }
                          else {
                              qs.limit = this.getNodeParameter('limit', 0);
                              responseData = await GenericFunctions_1.s3ApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', bucketName, 'GET', '', '', qs, {}, {}, region);
                              responseData = responseData.splice(0, qs.limit);
                          }
                          if (Array.isArray(responseData)) {
                              responseData = responseData.filter((e) => !e.Key.endsWith('/') && e.Size !== '0');
                              if (qs.limit) {
                                  responseData = responseData.splice(0, qs.limit);
                              }
                          }
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      if (operation === 'upload') {
                          const bucketName = this.getNodeParameter('bucketName', i);
                          const fileName = this.getNodeParameter('fileName', i);
                          const isBinaryData = this.getNodeParameter('binaryData', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const tagsValues = this.getNodeParameter('tagsUi', i)
                              .tagsValues;
                          let path = '/';
                          let body;
                          if (additionalFields.requesterPays) {
                              headers['x-amz-request-payer'] = 'requester';
                          }
                          if (additionalFields.parentFolderKey) {
                              path = `/${additionalFields.parentFolderKey}/`;
                          }
                          if (additionalFields.storageClass) {
                              headers['x-amz-storage-class'] = (0, change_case_1.snakeCase)(additionalFields.storageClass).toUpperCase();
                          }
                          if (additionalFields.acl) {
                              headers['x-amz-acl'] = (0, change_case_1.paramCase)(additionalFields.acl);
                          }
                          if (additionalFields.grantFullControl) {
                              headers['x-amz-grant-full-control'] = '';
                          }
                          if (additionalFields.grantRead) {
                              headers['x-amz-grant-read'] = '';
                          }
                          if (additionalFields.grantReadAcp) {
                              headers['x-amz-grant-read-acp'] = '';
                          }
                          if (additionalFields.grantWriteAcp) {
                              headers['x-amz-grant-write-acp'] = '';
                          }
                          if (additionalFields.lockLegalHold) {
                              headers['x-amz-object-lock-legal-hold'] = additionalFields.lockLegalHold
                                  ? 'ON'
                                  : 'OFF';
                          }
                          if (additionalFields.lockMode) {
                              headers['x-amz-object-lock-mode'] = additionalFields.lockMode.toUpperCase();
                          }
                          if (additionalFields.lockRetainUntilDate) {
                              headers['x-amz-object-lock-retain-until-date'] =
                                  additionalFields.lockRetainUntilDate;
                          }
                          if (additionalFields.serverSideEncryption) {
                              headers['x-amz-server-side-encryption'] =
                                  additionalFields.serverSideEncryption;
                          }
                          if (additionalFields.encryptionAwsKmsKeyId) {
                              headers['x-amz-server-side-encryption-aws-kms-key-id'] =
                                  additionalFields.encryptionAwsKmsKeyId;
                          }
                          if (additionalFields.serverSideEncryptionContext) {
                              headers['x-amz-server-side-encryption-context'] =
                                  additionalFields.serverSideEncryptionContext;
                          }
                          if (additionalFields.serversideEncryptionCustomerAlgorithm) {
                              headers['x-amz-server-side-encryption-customer-algorithm'] =
                                  additionalFields.serversideEncryptionCustomerAlgorithm;
                          }
                          if (additionalFields.serversideEncryptionCustomerKey) {
                              headers['x-amz-server-side-encryption-customer-key'] =
                                  additionalFields.serversideEncryptionCustomerKey;
                          }
                          if (additionalFields.serversideEncryptionCustomerKeyMD5) {
                              headers['x-amz-server-side-encryption-customer-key-MD5'] =
                                  additionalFields.serversideEncryptionCustomerKeyMD5;
                          }
                          if (tagsValues) {
                              const tags = [];
                              tagsValues.forEach((o) => {
                                  tags.push(`${o.key}=${o.value}`);
                              });
                              headers['x-amz-tagging'] = tags.join('&');
                          }
                          responseData = await GenericFunctions_1.s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', {
                              location: '',
                          });
                          const region = responseData.LocationConstraint._;
                          if (isBinaryData) {
                              const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0);
                              const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
                              body = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
                              headers['Content-Type'] = binaryData.mimeType;
                              headers['Content-MD5'] = (0, crypto_1.createHash)('md5').update(body).digest('base64');
                              responseData = await GenericFunctions_1.s3ApiRequestSOAP.call(this, bucketName, 'PUT', `${path}${fileName || binaryData.fileName}`, body, qs, headers, {}, region);
                          }
                          else {
                              const fileContent = this.getNodeParameter('fileContent', i);
                              body = Buffer.from(fileContent, 'utf8');
                              headers['Content-Type'] = 'text/html';
                              headers['Content-MD5'] = (0, crypto_1.createHash)('md5').update(fileContent).digest('base64');
                              responseData = await GenericFunctions_1.s3ApiRequestSOAP.call(this, bucketName, 'PUT', `${path}${fileName}`, body, qs, headers, {}, region);
                          }
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ success: true }), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                  }
              }
              catch (error) {
                  if (this.continueOnFail()) {
                      if (resource === 'file' && operation === 'download') {
                          items[i].json = { error: error.message };
                      }
                      else {
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      continue;
                  }
                  throw error;
              }
          }
          if (resource === 'file' && operation === 'download') {
              return [items];
          }
          return [returnData];
      }
  }
  exports.S3 = S3;
  //# sourceMappingURL=S3.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: S3 credentials
  description: Documentation for S3 credentials. Use these credentials to authenticate S3 in n8n, a workflow automation platform.
  contentType: [integration, reference]
  priority: medium
  ---

  # S3 credentials

  You can use these credentials to authenticate the following nodes:

  - [S3](/integrations/builtin/app-nodes/n8n-nodes-base.s3.md)

  ## Prerequisites

  Create an account on an S3-compatible server. Use the S3 node for generic or non-AWS S3 like:

  * [DigitalOcean Spaces](https://www.digitalocean.com/products/spaces){:target="_blank" .external-link}
  * [MinIO](https://min.io/){:target="_blank" .external-link}
  * [Wasabi](https://wasabi.com/){:target="_blank" .external-link}

  ## Supported authentication methods

  - S3 endpoint

  ## Related resources

  Refer to your S3-compatible provider's documentation for more information on the services. For example, refer to [Wasabi's REST API documentation](https://docs.wasabi.com/docs/rest-api-introduction){:target="_blank" .external-link} or [DigitalOcean's Spaces API Reference Documentation](https://docs.digitalocean.com/reference/api/spaces-api/){:target="_blank" .external-link}.

  ## Using S3 endpoint

  To configure this credential, you'll need:

  - An **S3 Endpoint**: Enter the URL endpoint for the S3 storage backend.
  - A **Region**: Enter the region for your S3 storage. Some providers call this the "region slug."
  - An **Access Key ID**: Enter the S3 access key your S3 provider uses to access the bucket or space. Some providers call this API keys.
  - A **Secret Access Key**: Enter the secret access key for the **Access Key ID**.
  - **Force Path Style**: When turned on, the connection uses path-style addressing for buckets.
  - **Ignore SSL Issues**: When turned on, n8n will connect even if SSL certificate validation fails.

  More detailed instructions for DigitalOcean Spaces and Wasabi follow. If you're using a different provider, refer to their documentation for more information. 

  ### Using DigitalOcean Spaces

  To configure the credential for use with DigitalOcean spaces:

  1. In DigitalOceans, go to the control panel and open **Settings**. Your endpoint should be listed there. Prepend `https://` to that endpoint and enter it as the **S3 Endpoint** in n8n.
      - Your DigitalOceans endpoint depends on the data center region your bucket's in.
  2. For the **Region**, enter the region your bucket's located in, for example, `nyc3`.
      - If you plan to use this credential to create new Spaces, enter `us-east-1` instead.
  3. From your DigitalOceans control panel, go to [**API**](https://cloud.digitalocean.com/account/api/spaces){:target="_blank" .external-link}.
  4. Open the **Spaces Keys** tab.
  5. Select **Generate New Key**.
  6. Enter a **Name** for your key, like `n8n integration` and select the checkmark.
  7. Copy the **Key** displayed next to the name and enter this as the **Access Key ID** in n8n.
  8. Copy the **Secret** value and enter this as the **Secret Access Key** in n8n.
      - Refer to [Sharing Access to Buckets with Access Keys](https://docs.digitalocean.com/products/spaces/how-to/manage-access/#access-keys){:target="_blank" .external-link} for more information on generating the key and secret.
  9. Keep the **Force Path Style** toggle turned off unless you want to use subdomain/virtual calling format.
  10. Decide how you want the n8n credential to handle SSL:
      - To respect SSL certificate validation, keep the default of **Ignore SSL Issues** turned off.
      - To connect even if SSL certificate validation fails, turn on **Ignore SSL Issues**.

  Refer to DigitalOcean's [Spaces API Reference Documentation](https://docs.digitalocean.com/reference/api/spaces-api/){:target="_blank" .external-link} for more information.

  ### Using Wasabi

  To configure the credential for use with Wasabi:

  1. For the **S3 Endpoint**, enter the service URL for your bucket's region. Start it with `https://`.
      - Refer to [What are the service URLs for Wasabi's different storage regions?](https://knowledgebase.wasabi.com/hc/en-us/articles/360015106031-What-are-the-service-URLs-for-Wasabi-s-different-storage-regions){:target="_blank" .external-link} to identify the correct URL.
  2. For the **Region**, enter the region slug portion of the service URL. For example, if you entered `https://s3.us-east-2.wasabisys.com` as the **S3 Endpoint**, `us-east-2` is the region.
  3. Log into you Wasabi Console as the root user.
  4. Open the **Menu** and select **Access Keys**.
  5. Select **CREATE NEW ACCESS KEY**.
  6. Select whether the key is for the **Root User** or a **Sub-User** and select **CREATE**.
  7. Copy the **Access Key** and enter it in n8n as the **Access Key ID**.
  8. Copy the **Secret Key** and enter it in n8n as the **Secret Access Key**.
      - Refer to [Creating a Wasabi API Access Key Set](https://knowledgebase.wasabi.com/hc/en-us/articles/360019677192-Creating-a-Wasabi-API-Access-Key-Set){:target="_blank" .external-link} for more information on generating the key and secret.
  9. Wasabi recommends turning on the **Force Path Style** toggle "because the path-style offers the greatest flexibility in bucket names, avoiding domain name issues." Refer to the Wasabi [REST API Introduction](https://docs.wasabi.com/docs/rest-api-introduction){:target="_blank" .external-link} for more information.
  10. Decide how you want the n8n credential to handle SSL:
      - To respect SSL certificate validation, keep the default of **Ignore SSL Issues** turned off.
      - To connect even if SSL certificate validation fails, turn on **Ignore SSL Issues**.

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"4536c50f-9c71-4f07-9b90-8e7a64d9b5a0","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"b89d8639f6f0ef62d236f0fce1868ce6ac67e99fb6012cc6931fec4fcafc15a1"}}


node_type: n8n-nodes-base.SendGrid
name: SendGrid
display_name: SendGrid
description: Consume SendGrid API
category: Other
code_hash: c682d47a8e16769aa94a9421671141e4f81eee92760eabbe45af312286758989
documentation_url: https://docs.n8n.io/integrations/builtin/credentials/sendgrid
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
extracted_at: 2025-06-08 08:05:29
updated_at: 2025-06-08 08:05:29
source_code:
  "use strict";
  var __importDefault = (this && this.__importDefault) || function (mod) {
      return (mod && mod.__esModule) ? mod : { "default": mod };
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.SendGrid = void 0;
  const ListDescription_1 = require("./ListDescription");
  const ContactDescription_1 = require("./ContactDescription");
  const MailDescription_1 = require("./MailDescription");
  const GenericFunctions_1 = require("./GenericFunctions");
  const moment_timezone_1 = __importDefault(require("moment-timezone"));
  class SendGrid {
      constructor() {
          this.description = {
              displayName: 'SendGrid',
              name: 'sendGrid',
              icon: 'file:sendGrid.svg',
              group: ['transform'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ":" + $parameter["resource"]}}',
              description: 'Consume SendGrid API',
              defaults: {
                  name: 'SendGrid',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'sendGridApi',
                      required: true,
                  },
              ],
              properties: [
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Contact',
                              value: 'contact',
                          },
                          {
                              name: 'List',
                              value: 'list',
                          },
                          {
                              name: 'Mail',
                              value: 'mail',
                          },
                      ],
                      default: 'list',
                      required: true,
                  },
                  ...ListDescription_1.listOperations,
                  ...ListDescription_1.listFields,
                  ...ContactDescription_1.contactOperations,
                  ...ContactDescription_1.contactFields,
                  ...MailDescription_1.mailOperations,
                  ...MailDescription_1.mailFields,
              ],
          };
          this.methods = {
              loadOptions: {
                  async getCustomFields() {
                      const returnData = [];
                      const { custom_fields } = await GenericFunctions_1.sendGridApiRequest.call(this, '/marketing/field_definitions', 'GET', {}, {});
                      if (custom_fields !== undefined) {
                          for (const customField of custom_fields) {
                              returnData.push({
                                  name: customField.name,
                                  value: customField.id,
                              });
                          }
                      }
                      return returnData;
                  },
                  async getListIds() {
                      const returnData = [];
                      const lists = await GenericFunctions_1.sendGridApiRequestAllItems.call(this, '/marketing/lists', 'GET', 'result', {}, {});
                      for (const list of lists) {
                          returnData.push({
                              name: list.name,
                              value: list.id,
                          });
                      }
                      return returnData;
                  },
                  async getTemplateIds() {
                      const responseData = await GenericFunctions_1.sendGridApiRequest.call(this, '/templates', 'GET', {}, { generations: 'dynamic' });
                      return responseData.templates.map(({ id, name }) => ({
                          name,
                          value: id,
                      }));
                  },
              },
          };
      }
      async execute() {
          const items = this.getInputData();
          const length = items.length;
          const qs = {};
          let responseData;
          const timezone = this.getTimezone();
          const returnData = [];
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          if (resource === 'contact') {
              if (operation === 'getAll') {
                  for (let i = 0; i < length; i++) {
                      try {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const filters = this.getNodeParameter('filters', i);
                          let endpoint = '/marketing/contacts';
                          let method = 'GET';
                          const body = {};
                          if (filters.query && filters.query !== '') {
                              endpoint = '/marketing/contacts/search';
                              method = 'POST';
                              Object.assign(body, { query: filters.query });
                          }
                          responseData = await GenericFunctions_1.sendGridApiRequestAllItems.call(this, endpoint, method, 'result', body, qs);
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              responseData = responseData.splice(0, limit);
                          }
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
              if (operation === 'get') {
                  const by = this.getNodeParameter('by', 0);
                  let endpoint;
                  let method;
                  const body = {};
                  for (let i = 0; i < length; i++) {
                      try {
                          if (by === 'id') {
                              method = 'GET';
                              const contactId = this.getNodeParameter('contactId', i);
                              endpoint = `/marketing/contacts/${contactId}`;
                          }
                          else {
                              const email = this.getNodeParameter('email', i);
                              endpoint = '/marketing/contacts/search';
                              method = 'POST';
                              Object.assign(body, { query: `email LIKE '${email}' ` });
                          }
                          responseData = await GenericFunctions_1.sendGridApiRequest.call(this, endpoint, method, body, qs);
                          responseData = responseData.result || responseData;
                          if (Array.isArray(responseData)) {
                              responseData = responseData[0];
                          }
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
              if (operation === 'upsert') {
                  try {
                      const contacts = [];
                      let lists;
                      for (let i = 0; i < length; i++) {
                          const email = this.getNodeParameter('email', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const contact = {
                              email,
                          };
                          if (additionalFields.addressUi) {
                              const addressValues = additionalFields.addressUi
                                  .addressValues;
                              const addressLine1 = addressValues.address1;
                              const addressLine2 = addressValues.address2;
                              if (addressLine2) {
                                  Object.assign(contact, { address_line_2: addressLine2 });
                              }
                              Object.assign(contact, { address_line_1: addressLine1 });
                          }
                          if (additionalFields.city) {
                              const city = additionalFields.city;
                              Object.assign(contact, { city });
                          }
                          if (additionalFields.country) {
                              const country = additionalFields.country;
                              Object.assign(contact, { country });
                          }
                          if (additionalFields.firstName) {
                              const firstName = additionalFields.firstName;
                              Object.assign(contact, { first_name: firstName });
                          }
                          if (additionalFields.lastName) {
                              const lastName = additionalFields.lastName;
                              Object.assign(contact, { last_name: lastName });
                          }
                          if (additionalFields.postalCode) {
                              const postalCode = additionalFields.postalCode;
                              Object.assign(contact, { postal_code: postalCode });
                          }
                          if (additionalFields.stateProvinceRegion) {
                              const stateProvinceRegion = additionalFields.stateProvinceRegion;
                              Object.assign(contact, { state_province_region: stateProvinceRegion });
                          }
                          if (additionalFields.alternateEmails) {
                              const alternateEmails = additionalFields.alternateEmails
                                  .split(',')
                                  .filter((mail) => !!mail);
                              if (alternateEmails.length !== 0) {
                                  Object.assign(contact, { alternate_emails: alternateEmails });
                              }
                          }
                          if (additionalFields.listIdsUi) {
                              const listIdValues = additionalFields.listIdsUi
                                  .listIdValues;
                              const listIds = listIdValues.listIds;
                              lists = listIds;
                          }
                          if (additionalFields.customFieldsUi) {
                              const customFields = additionalFields.customFieldsUi
                                  .customFieldValues;
                              if (customFields) {
                                  const data = customFields.reduce((obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }), {});
                                  Object.assign(contact, { custom_fields: data });
                              }
                          }
                          contacts.push(contact);
                      }
                      responseData = await GenericFunctions_1.sendGridApiRequest.call(this, '/marketing/contacts', 'PUT', { list_ids: lists, contacts }, qs);
                      returnData.push(responseData);
                  }
                  catch (error) {
                      if (this.continueOnFail()) {
                          returnData.push({ json: { error: error.message } });
                      }
                      else {
                          throw error;
                      }
                  }
              }
              if (operation === 'delete') {
                  for (let i = 0; i < length; i++) {
                      try {
                          const deleteAll = this.getNodeParameter('deleteAll', i);
                          if (deleteAll) {
                              qs.delete_all_contacts = 'true';
                          }
                          qs.ids = this.getNodeParameter('ids', i).replace(/\s/g, '');
                          responseData = await GenericFunctions_1.sendGridApiRequest.call(this, '/marketing/contacts', 'DELETE', {}, qs);
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
          }
          if (resource === 'list') {
              if (operation === 'getAll') {
                  for (let i = 0; i < length; i++) {
                      try {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          responseData = await GenericFunctions_1.sendGridApiRequestAllItems.call(this, '/marketing/lists', 'GET', 'result', {}, qs);
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              responseData = responseData.splice(0, limit);
                          }
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
              if (operation === 'get') {
                  for (let i = 0; i < length; i++) {
                      try {
                          const listId = this.getNodeParameter('listId', i);
                          qs.contact_sample = this.getNodeParameter('contactSample', i);
                          responseData = await GenericFunctions_1.sendGridApiRequest.call(this, `/marketing/lists/${listId}`, 'GET', {}, qs);
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
              if (operation === 'create') {
                  for (let i = 0; i < length; i++) {
                      try {
                          const name = this.getNodeParameter('name', i);
                          responseData = await GenericFunctions_1.sendGridApiRequest.call(this, '/marketing/lists', 'POST', { name }, qs);
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
              if (operation === 'delete') {
                  for (let i = 0; i < length; i++) {
                      try {
                          const listId = this.getNodeParameter('listId', i);
                          qs.delete_contacts = this.getNodeParameter('deleteContacts', i);
                          responseData = await GenericFunctions_1.sendGridApiRequest.call(this, `/marketing/lists/${listId}`, 'DELETE', {}, qs);
                          responseData = { success: true };
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
              if (operation === 'update') {
                  for (let i = 0; i < length; i++) {
                      try {
                          const name = this.getNodeParameter('name', i);
                          const listId = this.getNodeParameter('listId', i);
                          responseData = await GenericFunctions_1.sendGridApiRequest.call(this, `/marketing/lists/${listId}`, 'PATCH', { name }, qs);
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
          }
          if (resource === 'mail') {
              if (operation === 'send') {
                  for (let i = 0; i < length; i++) {
                      try {
                          const toEmail = this.getNodeParameter('toEmail', i);
                          const parsedToEmail = toEmail.includes(',')
                              ? toEmail.split(',').map((entry) => ({ email: entry.trim() }))
                              : [{ email: toEmail.trim() }];
                          const { bccEmail, ccEmail, enableSandbox, sendAt, headers, attachments, categories, ipPoolName, } = this.getNodeParameter('additionalFields', i);
                          const body = {
                              personalizations: [
                                  {
                                      to: parsedToEmail,
                                  },
                              ],
                              from: {
                                  email: this.getNodeParameter('fromEmail', i).trim(),
                                  name: this.getNodeParameter('fromName', i),
                              },
                              mail_settings: {
                                  sandbox_mode: {
                                      enable: enableSandbox || false,
                                  },
                              },
                          };
                          const dynamicTemplateEnabled = this.getNodeParameter('dynamicTemplate', i);
                          if (dynamicTemplateEnabled) {
                              body.template_id = this.getNodeParameter('templateId', i);
                              const { fields } = this.getNodeParameter('dynamicTemplateFields', i);
                              if (fields) {
                                  body.personalizations[0].dynamic_template_data = {};
                                  fields.forEach((field) => {
                                      body.personalizations[0].dynamic_template_data[field.key] = field.value;
                                  });
                              }
                          }
                          else {
                              body.personalizations[0].subject = this.getNodeParameter('subject', i);
                              body.content = [
                                  {
                                      type: this.getNodeParameter('contentType', i),
                                      value: this.getNodeParameter('contentValue', i),
                                  },
                              ];
                          }
                          if (attachments) {
                              const attachmentsToSend = [];
                              const binaryProperties = attachments.split(',').map((p) => p.trim());
                              for (const property of binaryProperties) {
                                  const binaryData = this.helpers.assertBinaryData(i, property);
                                  const dataBuffer = await this.helpers.getBinaryDataBuffer(i, property);
                                  attachmentsToSend.push({
                                      content: dataBuffer.toString('base64'),
                                      filename: binaryData.fileName || 'unknown',
                                      type: binaryData.mimeType,
                                  });
                              }
                              if (attachmentsToSend.length) {
                                  body.attachments = attachmentsToSend;
                              }
                          }
                          if (bccEmail) {
                              body.personalizations[0].bcc = bccEmail
                                  .split(',')
                                  .map((entry) => ({ email: entry.trim() }));
                          }
                          if (ccEmail) {
                              body.personalizations[0].cc = ccEmail
                                  .split(',')
                                  .map((entry) => ({ email: entry.trim() }));
                          }
                          if (headers === null || headers === void 0 ? void 0 : headers.details.length) {
                              const parsedHeaders = {};
                              headers.details.forEach((obj) => (parsedHeaders[obj.key] = obj.value));
                              body.headers = parsedHeaders;
                          }
                          if (categories) {
                              body.categories = categories.split(',');
                          }
                          if (ipPoolName) {
                              body.ip_pool_name = ipPoolName;
                          }
                          if (sendAt) {
                              body.personalizations[0].send_at = moment_timezone_1.default.tz(sendAt, timezone).unix();
                          }
                          const data = await GenericFunctions_1.sendGridApiRequest.call(this, '/mail/send', 'POST', body, qs, {
                              resolveWithFullResponse: true,
                          });
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ messageId: data.headers['x-message-id'] }), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
          }
          return [returnData];
      }
  }
  exports.SendGrid = SendGrid;
  //# sourceMappingURL=SendGrid.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: SendGrid credentials
  description: Documentation for SendGrid credentials. Use these credentials to authenticate SendGrid in n8n, a workflow automation platform.
  contentType: [integration, reference]
  priority: medium
  ---

  # SendGrid credentials

  You can use these credentials to authenticate the following nodes:

  - [SendGrid](/integrations/builtin/app-nodes/n8n-nodes-base.sendgrid.md)

  ## Supported authentication methods

  - API key

  ## Related resources

  Refer to [SendGrid's API documentation](https://www.twilio.com/docs/sendgrid/api-reference){:target=_blank .external-link} for more information about the service.

  ## Using API key

  To configure this credential, you'll need a [SendGrid](https://sendgrid.com){:target=_blank .external-link} account and:

  - An **API Key**

  To create an API key:

  1. In the Twilio SendGrid app, go to **Settings >** [**API Keys**](https://app.sendgrid.com/settings/api_keys){:target=_blank .external-link}.
  2. Select **Create API Key**.
  3. Enter a **Name** for your API key, like `n8n integration`.
  4. Select **Full Access**.
  5. Select **Create & View**.
  6. Copy the key and enter it in your n8n credential.

  Refer to [Create API Keys](https://www.twilio.com/docs/sendgrid/api-reference/api-keys/create-api-keys){:target=_blank .external-link} for more information.

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"c3c3696d-8949-4a9e-960f-6689d37477a7","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"877da571b256093939fdf5acb6babfd7929695f96f4778a8090546f7de157a02"}}


node_type: n8n-nodes-base.Sendy
name: Sendy
display_name: Sendy
description: Consume Sendy API
category: Other
code_hash: 8f1551f664c318139782631bc2298a5dc48d279198dcc99bfff803806441c8ab
documentation_url: https://docs.n8n.io/integrations/builtin/credentials/sendy
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
extracted_at: 2025-06-08 08:05:29
updated_at: 2025-06-08 08:05:29
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.Sendy = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const GenericFunctions_1 = require("./GenericFunctions");
  const CampaignDescription_1 = require("./CampaignDescription");
  const SubscriberDescription_1 = require("./SubscriberDescription");
  class Sendy {
      constructor() {
          this.description = {
              displayName: 'Sendy',
              name: 'sendy',
              icon: 'file:sendy.png',
              group: ['input'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
              description: 'Consume Sendy API',
              defaults: {
                  name: 'Sendy',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'sendyApi',
                      required: true,
                  },
              ],
              properties: [
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Campaign',
                              value: 'campaign',
                          },
                          {
                              name: 'Subscriber',
                              value: 'subscriber',
                          },
                      ],
                      default: 'subscriber',
                  },
                  ...CampaignDescription_1.campaignOperations,
                  ...CampaignDescription_1.campaignFields,
                  ...SubscriberDescription_1.subscriberOperations,
                  ...SubscriberDescription_1.subscriberFields,
              ],
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          const length = items.length;
          let responseData;
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          for (let i = 0; i < length; i++) {
              if (resource === 'campaign') {
                  if (operation === 'create') {
                      const fromName = this.getNodeParameter('fromName', i);
                      const fromEmail = this.getNodeParameter('fromEmail', i);
                      const replyTo = this.getNodeParameter('replyTo', i);
                      const title = this.getNodeParameter('title', i);
                      const subject = this.getNodeParameter('subject', i);
                      const htmlText = this.getNodeParameter('htmlText', i);
                      const sendCampaign = this.getNodeParameter('sendCampaign', i);
                      const additionalFields = this.getNodeParameter('additionalFields', i);
                      let brandId = null;
                      if (!sendCampaign) {
                          brandId = this.getNodeParameter('brandId', i);
                      }
                      const body = {
                          from_name: fromName,
                          from_email: fromEmail,
                          reply_to: replyTo,
                          title,
                          subject,
                          send_campaign: sendCampaign ? 1 : 0,
                          html_text: htmlText,
                      };
                      if (brandId) {
                          body.brand_id = brandId;
                      }
                      if (additionalFields.plainText) {
                          body.plain_text = additionalFields.plainText;
                      }
                      if (additionalFields.listIds) {
                          body.list_ids = additionalFields.listIds;
                      }
                      if (additionalFields.segmentIds) {
                          body.segment_ids = additionalFields.segmentIds;
                      }
                      if (additionalFields.excludeListIds) {
                          body.exclude_list_ids = additionalFields.excludeListIds;
                      }
                      if (additionalFields.excludeSegmentIds) {
                          body.exclude_segments_ids = additionalFields.excludeSegmentIds;
                      }
                      if (additionalFields.queryString) {
                          body.query_string = additionalFields.queryString;
                      }
                      if (additionalFields.trackOpens) {
                          body.track_opens = additionalFields.trackOpens ? 1 : 0;
                      }
                      if (additionalFields.trackClicks) {
                          body.track_clicks = additionalFields.trackClicks ? 1 : 0;
                      }
                      responseData = await GenericFunctions_1.sendyApiRequest.call(this, 'POST', '/api/campaigns/create.php', body);
                      const success = ['Campaign created', 'Campaign created and now sending'];
                      if (success.includes(responseData)) {
                          responseData = { message: responseData };
                      }
                      else {
                          throw new n8n_workflow_1.NodeApiError(this.getNode(), responseData, { httpCode: '400' });
                      }
                  }
              }
              if (resource === 'subscriber') {
                  if (operation === 'add') {
                      const email = this.getNodeParameter('email', i);
                      const listId = this.getNodeParameter('listId', i);
                      const additionalFields = this.getNodeParameter('additionalFields', i);
                      const body = {
                          email,
                          list: listId,
                      };
                      Object.assign(body, additionalFields);
                      responseData = await GenericFunctions_1.sendyApiRequest.call(this, 'POST', '/subscribe', body);
                      if (responseData === '1') {
                          responseData = { success: true };
                      }
                      else {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Sendy error response [${400}]: ${responseData}`, { itemIndex: i });
                      }
                  }
                  if (operation === 'count') {
                      const listId = this.getNodeParameter('listId', i);
                      const body = {
                          list_id: listId,
                      };
                      responseData = await GenericFunctions_1.sendyApiRequest.call(this, 'POST', '/api/subscribers/active-subscriber-count.php', body);
                      const errors = [
                          'No data passed',
                          'API key not passed',
                          'Invalid API key',
                          'List ID not passed',
                          'List does not exist',
                      ];
                      if (!errors.includes(responseData)) {
                          responseData = { count: responseData };
                      }
                      else {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Sendy error response [${400}]: ${responseData}`, { itemIndex: i });
                      }
                  }
                  if (operation === 'delete') {
                      const email = this.getNodeParameter('email', i);
                      const listId = this.getNodeParameter('listId', i);
                      const body = {
                          email,
                          list_id: listId,
                      };
                      responseData = await GenericFunctions_1.sendyApiRequest.call(this, 'POST', '/api/subscribers/delete.php', body);
                      if (responseData === '1') {
                          responseData = { success: true };
                      }
                      else {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Sendy error response [${400}]: ${responseData}`, { itemIndex: i });
                      }
                  }
                  if (operation === 'remove') {
                      const email = this.getNodeParameter('email', i);
                      const listId = this.getNodeParameter('listId', i);
                      const body = {
                          email,
                          list: listId,
                      };
                      responseData = await GenericFunctions_1.sendyApiRequest.call(this, 'POST', '/unsubscribe', body);
                      if (responseData === '1') {
                          responseData = { success: true };
                      }
                      else {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Sendy error response [${400}]: ${responseData}`, { itemIndex: i });
                      }
                  }
                  if (operation === 'status') {
                      const email = this.getNodeParameter('email', i);
                      const listId = this.getNodeParameter('listId', i);
                      const body = {
                          email,
                          list_id: listId,
                      };
                      responseData = await GenericFunctions_1.sendyApiRequest.call(this, 'POST', '/api/subscribers/subscription-status.php', body);
                      const status = [
                          'Subscribed',
                          'Unsubscribed',
                          'Unconfirmed',
                          'Bounced',
                          'Soft bounced',
                          'Complained',
                      ];
                      if (status.includes(responseData)) {
                          responseData = { status: responseData };
                      }
                      else {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Sendy error response [${400}]: ${responseData}`, { itemIndex: i });
                      }
                  }
              }
          }
          if (Array.isArray(responseData)) {
              returnData.push.apply(returnData, responseData);
          }
          else if (responseData !== undefined) {
              returnData.push(responseData);
          }
          return [this.helpers.returnJsonArray(returnData)];
      }
  }
  exports.Sendy = Sendy;
  //# sourceMappingURL=Sendy.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Sendy credentials
  description: Documentation for Sendy credentials. Use these credentials to authenticate Sendy in n8n, a workflow automation platform.
  contentType: [integration, reference]
  ---

  # Sendy credentials

  You can use these credentials to authenticate the following nodes:

  - [Sendy](/integrations/builtin/app-nodes/n8n-nodes-base.sendy.md)

  ## Prerequisites

  Host a [Sendy](https://sendy.co/get-started){:target=_blank .external-link} application.

  ## Supported authentication methods

  - API key

  ## Related resources

  Refer to [Sendy's API documentation](https://sendy.co/api){:target=_blank .external-link} for more information about the service.

  ## Using API Key

  To configure this credential, you'll need:

  - A **URL**: The URL of your Sendy application.
  - An **API Key**: Get your API key from your user profile > **Settings > Your API Key**.

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"78b706ae-4380-4e99-a9a3-8aae1d73d792","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"d93f35d5543b433bbb99e188e3627de7ef661fdb7f87292224e5759ebd716b46"}}


node_type: n8n-nodes-base.SentryIo
name: SentryIo
display_name: Sentry.io
description: Consume Sentry.io API
category: Other
code_hash: 12e647ea8cb08abfa06aba35b9341919467decb8126ef162439de5714292bc31
documentation_url: https://docs.n8n.io/integrations/builtin/credentials/sentryio
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
extracted_at: 2025-06-08 08:05:29
updated_at: 2025-06-08 08:05:29
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.SentryIo = void 0;
  const EventDescription_1 = require("./EventDescription");
  const IssueDescription_1 = require("./IssueDescription");
  const OrganizationDescription_1 = require("./OrganizationDescription");
  const ProjectDescription_1 = require("./ProjectDescription");
  const ReleaseDescription_1 = require("./ReleaseDescription");
  const TeamDescription_1 = require("./TeamDescription");
  const GenericFunctions_1 = require("./GenericFunctions");
  class SentryIo {
      constructor() {
          this.description = {
              displayName: 'Sentry.io',
              name: 'sentryIo',
              icon: 'file:sentryio.svg',
              group: ['output'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
              description: 'Consume Sentry.io API',
              defaults: {
                  name: 'Sentry.io',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'sentryIoOAuth2Api',
                      required: true,
                      displayOptions: {
                          show: {
                              authentication: ['oAuth2'],
                              sentryVersion: ['cloud'],
                          },
                      },
                  },
                  {
                      name: 'sentryIoApi',
                      required: true,
                      displayOptions: {
                          show: {
                              authentication: ['accessToken'],
                              sentryVersion: ['cloud'],
                          },
                      },
                  },
                  {
                      name: 'sentryIoServerApi',
                      required: true,
                      displayOptions: {
                          show: {
                              authentication: ['accessToken'],
                              sentryVersion: ['server'],
                          },
                      },
                  },
              ],
              properties: [
                  {
                      displayName: 'Sentry Version',
                      name: 'sentryVersion',
                      type: 'options',
                      options: [
                          {
                              name: 'Cloud',
                              value: 'cloud',
                          },
                          {
                              name: 'Server (Self Hosted)',
                              value: 'server',
                          },
                      ],
                      default: 'cloud',
                  },
                  {
                      displayName: 'Authentication',
                      name: 'authentication',
                      type: 'options',
                      displayOptions: {
                          show: {
                              sentryVersion: ['cloud'],
                          },
                      },
                      options: [
                          {
                              name: 'Access Token',
                              value: 'accessToken',
                          },
                          {
                              name: 'OAuth2',
                              value: 'oAuth2',
                          },
                      ],
                      default: 'accessToken',
                  },
                  {
                      displayName: 'Authentication',
                      name: 'authentication',
                      type: 'options',
                      displayOptions: {
                          show: {
                              sentryVersion: ['server'],
                          },
                      },
                      options: [
                          {
                              name: 'Access Token',
                              value: 'accessToken',
                          },
                      ],
                      default: 'accessToken',
                  },
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Event',
                              value: 'event',
                          },
                          {
                              name: 'Issue',
                              value: 'issue',
                          },
                          {
                              name: 'Organization',
                              value: 'organization',
                          },
                          {
                              name: 'Project',
                              value: 'project',
                          },
                          {
                              name: 'Release',
                              value: 'release',
                          },
                          {
                              name: 'Team',
                              value: 'team',
                          },
                      ],
                      default: 'event',
                  },
                  ...EventDescription_1.eventOperations,
                  ...EventDescription_1.eventFields,
                  ...IssueDescription_1.issueOperations,
                  ...IssueDescription_1.issueFields,
                  ...OrganizationDescription_1.organizationOperations,
                  ...OrganizationDescription_1.organizationFields,
                  ...ProjectDescription_1.projectOperations,
                  ...ProjectDescription_1.projectFields,
                  ...ReleaseDescription_1.releaseOperations,
                  ...ReleaseDescription_1.releaseFields,
                  ...TeamDescription_1.teamOperations,
                  ...TeamDescription_1.teamFields,
              ],
          };
          this.methods = {
              loadOptions: {
                  async getOrganizations() {
                      const returnData = [];
                      const organizations = await GenericFunctions_1.sentryApiRequestAllItems.call(this, 'GET', '/api/0/organizations/', {});
                      for (const organization of organizations) {
                          returnData.push({
                              name: organization.slug,
                              value: organization.slug,
                          });
                      }
                      returnData.sort((a, b) => {
                          if (a.name < b.name) {
                              return -1;
                          }
                          if (a.name > b.name) {
                              return 1;
                          }
                          return 0;
                      });
                      return returnData;
                  },
                  async getProjects() {
                      const returnData = [];
                      const projects = await GenericFunctions_1.sentryApiRequestAllItems.call(this, 'GET', '/api/0/projects/', {});
                      const organizationSlug = this.getNodeParameter('organizationSlug');
                      for (const project of projects) {
                          if (organizationSlug !== project.organization.slug) {
                              continue;
                          }
                          returnData.push({
                              name: project.slug,
                              value: project.slug,
                          });
                      }
                      returnData.sort((a, b) => {
                          if (a.name < b.name) {
                              return -1;
                          }
                          if (a.name > b.name) {
                              return 1;
                          }
                          return 0;
                      });
                      return returnData;
                  },
                  async getTeams() {
                      const returnData = [];
                      const organizationSlug = this.getNodeParameter('organizationSlug');
                      const teams = await GenericFunctions_1.sentryApiRequestAllItems.call(this, 'GET', `/api/0/organizations/${organizationSlug}/teams/`, {});
                      for (const team of teams) {
                          returnData.push({
                              name: team.slug,
                              value: team.slug,
                          });
                      }
                      returnData.sort((a, b) => {
                          if (a.name < b.name) {
                              return -1;
                          }
                          if (a.name > b.name) {
                              return 1;
                          }
                          return 0;
                      });
                      return returnData;
                  },
              },
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          const length = items.length;
          let responseData;
          const qs = {};
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          for (let i = 0; i < length; i++) {
              try {
                  if (resource === 'event') {
                      if (operation === 'getAll') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const projectSlug = this.getNodeParameter('projectSlug', i);
                          const full = this.getNodeParameter('full', i);
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const endpoint = `/api/0/projects/${organizationSlug}/${projectSlug}/events/`;
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.limit = limit;
                          }
                          qs.full = full;
                          responseData = await GenericFunctions_1.sentryApiRequestAllItems.call(this, 'GET', endpoint, {}, qs);
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              responseData = responseData.splice(0, limit);
                          }
                      }
                      if (operation === 'get') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const projectSlug = this.getNodeParameter('projectSlug', i);
                          const eventId = this.getNodeParameter('eventId', i);
                          const endpoint = `/api/0/projects/${organizationSlug}/${projectSlug}/events/${eventId}/`;
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'GET', endpoint, qs);
                      }
                  }
                  if (resource === 'issue') {
                      if (operation === 'getAll') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const projectSlug = this.getNodeParameter('projectSlug', i);
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const endpoint = `/api/0/projects/${organizationSlug}/${projectSlug}/issues/`;
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (additionalFields.statsPeriod) {
                              qs.statsPeriod = additionalFields.statsPeriod;
                          }
                          if (additionalFields.shortIdLookup) {
                              qs.shortIdLookup = additionalFields.shortIdLookup;
                          }
                          if (additionalFields.query) {
                              qs.query = additionalFields.query;
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.limit = limit;
                          }
                          responseData = await GenericFunctions_1.sentryApiRequestAllItems.call(this, 'GET', endpoint, {}, qs);
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              responseData = responseData.splice(0, limit);
                          }
                      }
                      if (operation === 'get') {
                          const issueId = this.getNodeParameter('issueId', i);
                          const endpoint = `/api/0/issues/${issueId}/`;
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'GET', endpoint, qs);
                      }
                      if (operation === 'delete') {
                          const issueId = this.getNodeParameter('issueId', i);
                          const endpoint = `/api/0/issues/${issueId}/`;
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'DELETE', endpoint, qs);
                          responseData = { success: true };
                      }
                      if (operation === 'update') {
                          const issueId = this.getNodeParameter('issueId', i);
                          const endpoint = `/api/0/issues/${issueId}/`;
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (additionalFields.status) {
                              qs.status = additionalFields.status;
                          }
                          if (additionalFields.assignedTo) {
                              qs.assignedTo = additionalFields.assignedTo;
                          }
                          if (additionalFields.hasSeen) {
                              qs.hasSeen = additionalFields.hasSeen;
                          }
                          if (additionalFields.isBookmarked) {
                              qs.isBookmarked = additionalFields.isBookmarked;
                          }
                          if (additionalFields.isSubscribed) {
                              qs.isSubscribed = additionalFields.isSubscribed;
                          }
                          if (additionalFields.isPublic) {
                              qs.isPublic = additionalFields.isPublic;
                          }
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'PUT', endpoint, qs);
                      }
                  }
                  if (resource === 'organization') {
                      if (operation === 'get') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const endpoint = `/api/0/organizations/${organizationSlug}/`;
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'GET', endpoint, qs);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const endpoint = '/api/0/organizations/';
                          if (additionalFields.member) {
                              qs.member = additionalFields.member;
                          }
                          if (additionalFields.owner) {
                              qs.owner = additionalFields.owner;
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.limit = limit;
                          }
                          responseData = await GenericFunctions_1.sentryApiRequestAllItems.call(this, 'GET', endpoint, {}, qs);
                          if (responseData === undefined) {
                              responseData = [];
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              responseData = responseData.splice(0, limit);
                          }
                      }
                      if (operation === 'create') {
                          const name = this.getNodeParameter('name', i);
                          const agreeTerms = this.getNodeParameter('agreeTerms', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const endpoint = '/api/0/organizations/';
                          qs.name = name;
                          qs.agreeTerms = agreeTerms;
                          if (additionalFields.slug) {
                              qs.slug = additionalFields.slug;
                          }
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'POST', endpoint, qs);
                      }
                      if (operation === 'update') {
                          const organizationSlug = this.getNodeParameter('organization_slug', i);
                          const endpoint = `/api/0/organizations/${organizationSlug}/`;
                          const body = this.getNodeParameter('updateFields', i);
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'PUT', endpoint, body, qs);
                      }
                  }
                  if (resource === 'project') {
                      if (operation === 'create') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const teamSlug = this.getNodeParameter('teamSlug', i);
                          const name = this.getNodeParameter('name', i);
                          const endpoint = `/api/0/teams/${organizationSlug}/${teamSlug}/projects/`;
                          const body = {
                              name,
                              ...this.getNodeParameter('additionalFields', i),
                          };
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'POST', endpoint, body, qs);
                      }
                      if (operation === 'get') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const projectSlug = this.getNodeParameter('projectSlug', i);
                          const endpoint = `/api/0/projects/${organizationSlug}/${projectSlug}/`;
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'GET', endpoint, qs);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const endpoint = '/api/0/projects/';
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.limit = limit;
                          }
                          responseData = await GenericFunctions_1.sentryApiRequestAllItems.call(this, 'GET', endpoint, {}, qs);
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              responseData = responseData.splice(0, limit);
                          }
                      }
                      if (operation === 'update') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const projectSlug = this.getNodeParameter('projectSlug', i);
                          const endpoint = `/api/0/projects/${organizationSlug}/${projectSlug}/`;
                          const body = this.getNodeParameter('updateFields', i);
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'PUT', endpoint, body, qs);
                      }
                      if (operation === 'delete') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const projectSlug = this.getNodeParameter('projectSlug', i);
                          const endpoint = `/api/0/projects/${organizationSlug}/${projectSlug}/`;
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'DELETE', endpoint, qs);
                          responseData = { success: true };
                      }
                  }
                  if (resource === 'release') {
                      if (operation === 'get') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const version = this.getNodeParameter('version', i);
                          const endpoint = `/api/0/organizations/${organizationSlug}/releases/${version}/`;
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'GET', endpoint, qs);
                      }
                      if (operation === 'getAll') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const endpoint = `/api/0/organizations/${organizationSlug}/releases/`;
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const returnAll = this.getNodeParameter('returnAll', i);
                          if (additionalFields.query) {
                              qs.query = additionalFields.query;
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.limit = limit;
                          }
                          responseData = await GenericFunctions_1.sentryApiRequestAllItems.call(this, 'GET', endpoint, {}, qs);
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              responseData = responseData.splice(0, limit);
                          }
                      }
                      if (operation === 'delete') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const version = this.getNodeParameter('version', i);
                          const endpoint = `/api/0/organizations/${organizationSlug}/releases/${version}/`;
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'DELETE', endpoint, qs);
                          responseData = { success: true };
                      }
                      if (operation === 'create') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const endpoint = `/api/0/organizations/${organizationSlug}/releases/`;
                          const version = this.getNodeParameter('version', i);
                          const url = this.getNodeParameter('url', i);
                          const projects = this.getNodeParameter('projects', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (additionalFields.dateReleased) {
                              qs.dateReleased = additionalFields.dateReleased;
                          }
                          qs.version = version;
                          qs.url = url;
                          qs.projects = projects;
                          if (additionalFields.commits) {
                              const commits = [];
                              additionalFields.commits.commitProperties.map((commit) => {
                                  const commitObject = { id: commit.id };
                                  if (commit.repository) {
                                      commitObject.repository = commit.repository;
                                  }
                                  if (commit.message) {
                                      commitObject.message = commit.message;
                                  }
                                  if (commit.patchSet && Array.isArray(commit.patchSet)) {
                                      commit.patchSet.patchSetProperties.map((patchSet) => {
                                          var _a;
                                          (_a = commitObject.patch_set) === null || _a === void 0 ? void 0 : _a.push(patchSet);
                                      });
                                  }
                                  if (commit.authorName) {
                                      commitObject.author_name = commit.authorName;
                                  }
                                  if (commit.authorEmail) {
                                      commitObject.author_email = commit.authorEmail;
                                  }
                                  if (commit.timestamp) {
                                      commitObject.timestamp = commit.timestamp;
                                  }
                                  commits.push(commitObject);
                              });
                              qs.commits = commits;
                          }
                          if (additionalFields.refs) {
                              const refs = [];
                              additionalFields.refs.refProperties.map((ref) => {
                                  refs.push(ref);
                              });
                              qs.refs = refs;
                          }
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'POST', endpoint, qs);
                      }
                      if (operation === 'update') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const version = this.getNodeParameter('version', i);
                          const endpoint = `/api/0/organizations/${organizationSlug}/releases/${version}/`;
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const body = { ...updateFields };
                          if (updateFields.commits) {
                              const commits = [];
                              updateFields.commits.commitProperties.map((commit) => {
                                  const commitObject = { id: commit.id };
                                  if (commit.repository) {
                                      commitObject.repository = commit.repository;
                                  }
                                  if (commit.message) {
                                      commitObject.message = commit.message;
                                  }
                                  if (commit.patchSet && Array.isArray(commit.patchSet)) {
                                      commit.patchSet.patchSetProperties.map((patchSet) => {
                                          var _a;
                                          (_a = commitObject.patch_set) === null || _a === void 0 ? void 0 : _a.push(patchSet);
                                      });
                                  }
                                  if (commit.authorName) {
                                      commitObject.author_name = commit.authorName;
                                  }
                                  if (commit.authorEmail) {
                                      commitObject.author_email = commit.authorEmail;
                                  }
                                  if (commit.timestamp) {
                                      commitObject.timestamp = commit.timestamp;
                                  }
                                  commits.push(commitObject);
                              });
                              body.commits = commits;
                          }
                          if (updateFields.refs) {
                              const refs = [];
                              updateFields.refs.refProperties.map((ref) => {
                                  refs.push(ref);
                              });
                              body.refs = refs;
                          }
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'PUT', endpoint, body, qs);
                      }
                  }
                  if (resource === 'team') {
                      if (operation === 'get') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const teamSlug = this.getNodeParameter('teamSlug', i);
                          const endpoint = `/api/0/teams/${organizationSlug}/${teamSlug}/`;
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'GET', endpoint, qs);
                      }
                      if (operation === 'getAll') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const endpoint = `/api/0/organizations/${organizationSlug}/teams/`;
                          const returnAll = this.getNodeParameter('returnAll', i);
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.limit = limit;
                          }
                          responseData = await GenericFunctions_1.sentryApiRequestAllItems.call(this, 'GET', endpoint, {}, qs);
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              responseData = responseData.splice(0, limit);
                          }
                      }
                      if (operation === 'create') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const name = this.getNodeParameter('name', i);
                          const endpoint = `/api/0/organizations/${organizationSlug}/teams/`;
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          qs.name = name;
                          if (additionalFields.slug) {
                              qs.slug = additionalFields.slug;
                          }
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'POST', endpoint, qs);
                      }
                      if (operation === 'update') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const teamSlug = this.getNodeParameter('teamSlug', i);
                          const endpoint = `/api/0/teams/${organizationSlug}/${teamSlug}/`;
                          const body = this.getNodeParameter('updateFields', i);
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'PUT', endpoint, body, qs);
                      }
                      if (operation === 'delete') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const teamSlug = this.getNodeParameter('teamSlug', i);
                          const endpoint = `/api/0/teams/${organizationSlug}/${teamSlug}/`;
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'DELETE', endpoint, qs);
                          responseData = { success: true };
                      }
                  }
                  const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                  returnData.push(...executionData);
              }
              catch (error) {
                  if (this.continueOnFail()) {
                      const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                      returnData.push(...executionErrorData);
                      continue;
                  }
                  throw error;
              }
          }
          return [returnData];
      }
  }
  exports.SentryIo = SentryIo;
  //# sourceMappingURL=SentryIo.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Sentry.io credentials
  description: Documentation for Sentry.io credentials. Use these credentials to authenticate Sentry.io in n8n, a workflow automation platform.
  contentType: [integration, reference]
  ---

  # Sentry.io credentials

  You can use these credentials to authenticate the following nodes:

  - [Sentry.io](/integrations/builtin/app-nodes/n8n-nodes-base.sentryio.md)

  ## Prerequisites

  Create a [Sentry.io](https://sentry.io/){:target=_blank .external-link} account.

  ## Supported authentication methods

  - API token
  - OAuth2
  - Server API token: Use for [self-hosted Sentry](https://develop.sentry.dev/self-hosted/){:target=_blank .external-link}.

  ## Related resources

  Refer to [Sentry.io's API documentation](https://docs.sentry.io/api/){:target=_blank .external-link} for more information about the service.

  ## Using API token

  To configure this credential, you'll need:

  - An API **Token**: Generate a [**User Auth Token**](https://sentry.io/settings/account/api/auth-tokens/){:target=_blank .external-link} in **Account > Settings > User Auth Tokens**. Refer to [User Auth Tokens](https://docs.sentry.io/account/auth-tokens/#user-auth-tokens){:target=_blank .external-link} for more information.

  ## Using OAuth

  --8<-- "_snippets/integrations/builtin/credentials/cloud-oauth-button.md"

  If you need to configure OAuth2 from scratch, [create an integration](https://docs.sentry.io/organization/integrations/integration-platform/#creating-an-integration){:target=_blank .external-link} with these settings:

  - Copy the n8n **OAuth Callback URL** and add it as an **Authorized Redirect URI**.
  - Copy the **Client ID** and **Client Secret** and add them to your n8n credential.

  Refer to [Public integrations](https://docs.sentry.io/organization/integrations/integration-platform/public-integration/){:target=_blank .external-link} for more information on creating the integration.

  ## Using Server API token

  To configure this credential, you'll need:

  - An API **Token**: Generate a [**User Auth Token**](https://sentry.io/settings/account/api/auth-tokens/){:target=_blank .external-link} in **Account > Settings > User Auth Tokens**. Refer to [User Auth Tokens](https://docs.sentry.io/account/auth-tokens/#user-auth-tokens){:target=_blank .external-link} for more information.
  - The **URL** of your self-hosted Sentry instance.

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"7c6eff55-bb3a-4b61-a7d4-d405c8e603db","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"86aee9d25645b407788277574622c3e31578fbaf9098ec4f769e016975821a45"}}


node_type: n8n-nodes-base.ServiceNow
name: ServiceNow
display_name: ServiceNow
description: Consume ServiceNow API
category: Other
code_hash: ff46288455e6d2f1a7f7f9bd7f3b80f839079d11a53c14846d3bf88f7f162af2
documentation_url: https://docs.n8n.io/integrations/builtin/credentials/servicenow
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
extracted_at: 2025-06-08 08:05:29
updated_at: 2025-06-08 08:05:29
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.ServiceNow = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const GenericFunctions_1 = require("./GenericFunctions");
  const AttachmentDescription_1 = require("./AttachmentDescription");
  const BusinessServiceDescription_1 = require("./BusinessServiceDescription");
  const ConfigurationItemsDescription_1 = require("./ConfigurationItemsDescription");
  const DepartmentDescription_1 = require("./DepartmentDescription");
  const DictionaryDescription_1 = require("./DictionaryDescription");
  const IncidentDescription_1 = require("./IncidentDescription");
  const TableRecordDescription_1 = require("./TableRecordDescription");
  const UserDescription_1 = require("./UserDescription");
  const UserGroupDescription_1 = require("./UserGroupDescription");
  const UserRoleDescription_1 = require("./UserRoleDescription");
  class ServiceNow {
      constructor() {
          this.description = {
              displayName: 'ServiceNow',
              name: 'serviceNow',
              icon: 'file:servicenow.svg',
              group: ['output'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
              description: 'Consume ServiceNow API',
              defaults: {
                  name: 'ServiceNow',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'serviceNowOAuth2Api',
                      required: true,
                      displayOptions: {
                          show: {
                              authentication: ['oAuth2'],
                          },
                      },
                  },
                  {
                      name: 'serviceNowBasicApi',
                      required: true,
                      displayOptions: {
                          show: {
                              authentication: ['basicAuth'],
                          },
                      },
                  },
              ],
              properties: [
                  {
                      displayName: 'Authentication',
                      name: 'authentication',
                      type: 'options',
                      options: [
                          {
                              name: 'Basic Auth',
                              value: 'basicAuth',
                          },
                          {
                              name: 'OAuth2',
                              value: 'oAuth2',
                          },
                      ],
                      default: 'oAuth2',
                      description: 'Authentication method to use',
                  },
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Attachment',
                              value: 'attachment',
                          },
                          {
                              name: 'Business Service',
                              value: 'businessService',
                          },
                          {
                              name: 'Configuration Item',
                              value: 'configurationItems',
                          },
                          {
                              name: 'Department',
                              value: 'department',
                          },
                          {
                              name: 'Dictionary',
                              value: 'dictionary',
                          },
                          {
                              name: 'Incident',
                              value: 'incident',
                          },
                          {
                              name: 'Table Record',
                              value: 'tableRecord',
                          },
                          {
                              name: 'User',
                              value: 'user',
                          },
                          {
                              name: 'User Group',
                              value: 'userGroup',
                          },
                          {
                              name: 'User Role',
                              value: 'userRole',
                          },
                      ],
                      default: 'user',
                  },
                  ...AttachmentDescription_1.attachmentOperations,
                  ...AttachmentDescription_1.attachmentFields,
                  ...BusinessServiceDescription_1.businessServiceOperations,
                  ...BusinessServiceDescription_1.businessServiceFields,
                  ...ConfigurationItemsDescription_1.configurationItemsOperations,
                  ...ConfigurationItemsDescription_1.configurationItemsFields,
                  ...DepartmentDescription_1.departmentOperations,
                  ...DepartmentDescription_1.departmentFields,
                  ...DictionaryDescription_1.dictionaryOperations,
                  ...DictionaryDescription_1.dictionaryFields,
                  ...IncidentDescription_1.incidentOperations,
                  ...IncidentDescription_1.incidentFields,
                  ...TableRecordDescription_1.tableRecordOperations,
                  ...TableRecordDescription_1.tableRecordFields,
                  ...UserDescription_1.userOperations,
                  ...UserDescription_1.userFields,
                  ...UserGroupDescription_1.userGroupOperations,
                  ...UserGroupDescription_1.userGroupFields,
                  ...UserRoleDescription_1.userRoleOperations,
                  ...UserRoleDescription_1.userRoleFields,
              ],
          };
          this.methods = {
              loadOptions: {
                  async getTables() {
                      const returnData = [];
                      const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/doc/table/schema', {}, {});
                      for (const table of response.result) {
                          returnData.push({
                              name: table.label,
                              value: table.value,
                              description: table.value,
                          });
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getColumns() {
                      const resource = this.getNodeParameter('resource', 0);
                      const operation = this.getNodeParameter('operation', 0);
                      const returnData = [];
                      let tableName;
                      if (resource === 'tableRecord') {
                          tableName = this.getNodeParameter('tableName');
                      }
                      else {
                          tableName = (0, GenericFunctions_1.mapEndpoint)(resource, operation);
                      }
                      const qs = {
                          sysparm_query: `name=${tableName}`,
                          sysparm_fields: 'column_label,element',
                      };
                      const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/sys_dictionary', {}, qs);
                      for (const column of response.result) {
                          if (column.element) {
                              returnData.push({
                                  name: column.column_label,
                                  value: column.element,
                              });
                          }
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getBusinessServices() {
                      const returnData = [];
                      const qs = {
                          sysparm_fields: 'name,sys_id',
                      };
                      const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/cmdb_ci_service', {}, qs);
                      for (const column of response.result) {
                          returnData.push({
                              name: column.name,
                              value: column.sys_id,
                          });
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getUsers() {
                      const returnData = [];
                      const resource = this.getNodeParameter('resource', 0);
                      const operation = this.getNodeParameter('operation', 0);
                      const qs = {
                          sysparm_fields: 'sys_id,user_name',
                      };
                      if (resource === 'incident' && operation === 'create') {
                          const additionalFields = this.getNodeParameter('additionalFields');
                          const group = additionalFields.assignment_group;
                          const response = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_user_grmember', {}, {
                              sysparm_query: `group=${group}^`,
                          });
                          for (const column of response) {
                              if (column.user) {
                                  const responseData = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', `/now/table/sys_user/${column.user.value}`, {}, {});
                                  const user = responseData.result;
                                  returnData.push({
                                      name: user.user_name,
                                      value: user.sys_id,
                                  });
                              }
                          }
                      }
                      else {
                          const response = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_user', {}, qs);
                          for (const column of response) {
                              if (column.user_name) {
                                  returnData.push({
                                      name: column.user_name,
                                      value: column.sys_id,
                                  });
                              }
                          }
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getAssignmentGroups() {
                      const returnData = [];
                      const qs = {
                          sysparm_fields: 'sys_id,name',
                      };
                      const response = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_user_group', {}, qs);
                      for (const column of response) {
                          if (column.name) {
                              returnData.push({
                                  name: column.name,
                                  value: column.sys_id,
                              });
                          }
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getUserRoles() {
                      const returnData = [];
                      const qs = {
                          sysparm_fields: 'sys_id,name',
                      };
                      const response = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_user_role', {}, qs);
                      for (const column of response) {
                          if (column.name) {
                              returnData.push({
                                  name: column.name,
                                  value: column.sys_id,
                              });
                          }
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getConfigurationItems() {
                      const returnData = [];
                      const qs = {
                          sysparm_fields: 'sys_id,name,sys_class_name',
                      };
                      const response = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/cmdb_ci', {}, qs);
                      for (const column of response) {
                          if (column.name) {
                              returnData.push({
                                  name: column.name,
                                  value: column.sys_id,
                                  description: column.sys_class_name,
                              });
                          }
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getIncidentCategories() {
                      const returnData = [];
                      const qs = {
                          sysparm_fields: 'label,value',
                          sysparm_query: 'element=category^name=incident',
                      };
                      const response = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_choice', {}, qs);
                      for (const column of response) {
                          returnData.push({
                              name: column.label,
                              value: column.value,
                          });
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getIncidentSubcategories() {
                      const returnData = [];
                      const operation = this.getNodeParameter('operation');
                      let category;
                      if (operation === 'update') {
                          const updateFields = this.getNodeParameter('updateFields');
                          category = updateFields.category;
                      }
                      else {
                          const additionalFields = this.getNodeParameter('additionalFields');
                          category = additionalFields.category;
                      }
                      const qs = {
                          sysparm_fields: 'label,value',
                          sysparm_query: `name=incident^element=subcategory^dependent_value=${category}`,
                      };
                      const response = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_choice', {}, qs);
                      for (const column of response) {
                          returnData.push({
                              name: column.label,
                              value: column.value,
                          });
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getIncidentStates() {
                      const returnData = [];
                      const qs = {
                          sysparm_fields: 'label,value',
                          sysparm_query: 'element=state^name=incident',
                      };
                      const response = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_choice', {}, qs);
                      for (const column of response) {
                          returnData.push({
                              name: column.label,
                              value: column.value,
                          });
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getIncidentResolutionCodes() {
                      const returnData = [];
                      const qs = {
                          sysparm_fields: 'label,value',
                          sysparm_query: 'element=close_code^name=incident',
                      };
                      const response = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_choice', {}, qs);
                      for (const column of response) {
                          returnData.push({
                              name: column.label,
                              value: column.value,
                          });
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getIncidentHoldReasons() {
                      const returnData = [];
                      const qs = {
                          sysparm_fields: 'label,value',
                          sysparm_query: 'element=hold_reason^name=incident',
                      };
                      const response = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_choice', {}, qs);
                      for (const column of response) {
                          returnData.push({
                              name: column.label,
                              value: column.value,
                          });
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
              },
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          const length = items.length;
          let responseData = {};
          let qs;
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          for (let i = 0; i < length; i++) {
              try {
                  if (resource === 'attachment') {
                      if (operation === 'get') {
                          const attachmentsSysId = this.getNodeParameter('attachmentId', i);
                          const download = this.getNodeParameter('download', i);
                          const endpoint = `/now/attachment/${attachmentsSysId}`;
                          const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', endpoint, {});
                          const fileMetadata = response.result;
                          responseData = {
                              json: fileMetadata,
                          };
                          if (download) {
                              const outputField = this.getNodeParameter('outputField', i);
                              responseData = {
                                  ...responseData,
                                  binary: {
                                      [outputField]: await GenericFunctions_1.serviceNowDownloadAttachment.call(this, endpoint, fileMetadata.file_name, fileMetadata.content_type),
                                  },
                              };
                          }
                      }
                      else if (operation === 'getAll') {
                          const download = this.getNodeParameter('download', i);
                          const tableName = this.getNodeParameter('tableName', i);
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          qs = {};
                          qs.sysparm_query = `table_name=${tableName}`;
                          if (options.queryFilter) {
                              qs.sysparm_query = `${qs.sysparm_query}^${options.queryFilter}`;
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.sysparm_limit = limit;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/attachment', {}, qs);
                              responseData = response.result;
                          }
                          else {
                              responseData = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/attachment', {}, qs);
                          }
                          if (download) {
                              const outputField = this.getNodeParameter('outputField', i);
                              const responseDataWithAttachments = [];
                              for (const data of responseData) {
                                  responseDataWithAttachments.push({
                                      json: data,
                                      binary: {
                                          [outputField]: await GenericFunctions_1.serviceNowDownloadAttachment.call(this, `/now/attachment/${data.sys_id}`, data.file_name, data.content_type),
                                      },
                                  });
                              }
                              responseData = responseDataWithAttachments;
                          }
                          else {
                              responseData = responseData.map((data) => ({ json: data }));
                          }
                      }
                      else if (operation === 'upload') {
                          const tableName = this.getNodeParameter('tableName', i);
                          const recordId = this.getNodeParameter('id', i);
                          const inputDataFieldName = this.getNodeParameter('inputDataFieldName', i);
                          const options = this.getNodeParameter('options', i);
                          const binaryData = this.helpers.assertBinaryData(i, inputDataFieldName);
                          const headers = {
                              'Content-Type': binaryData.mimeType,
                          };
                          const query = {
                              table_name: tableName,
                              table_sys_id: recordId,
                              file_name: binaryData.fileName
                                  ? binaryData.fileName
                                  : `${inputDataFieldName}.${binaryData.fileExtension}`,
                              ...options,
                          };
                          const body = await this.helpers.getBinaryDataBuffer(i, inputDataFieldName);
                          const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'POST', '/now/attachment/file', body, query, '', { headers });
                          responseData = response.result;
                      }
                      else if (operation === 'delete') {
                          const attachmentsSysId = this.getNodeParameter('attachmentId', i);
                          await GenericFunctions_1.serviceNowApiRequest.call(this, 'DELETE', `/now/attachment/${attachmentsSysId}`);
                          responseData = { success: true };
                      }
                  }
                  else if (resource === 'businessService') {
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.sysparm_limit = limit;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/cmdb_ci_service', {}, qs);
                              responseData = response.result;
                          }
                          else {
                              responseData = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/cmdb_ci_service', {}, qs);
                          }
                      }
                  }
                  else if (resource === 'configurationItems') {
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.sysparm_limit = limit;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/cmdb_ci', {}, qs);
                              responseData = response.result;
                          }
                          else {
                              responseData = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/cmdb_ci', {}, qs);
                          }
                      }
                  }
                  else if (resource === 'department') {
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.sysparm_limit = limit;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/cmn_department', {}, qs);
                              responseData = response.result;
                          }
                          else {
                              responseData = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/cmn_department', {}, qs);
                          }
                      }
                  }
                  else if (resource === 'dictionary') {
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.sysparm_limit = limit;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/sys_dictionary', {}, qs);
                              responseData = response.result;
                          }
                          else {
                              responseData = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_dictionary', {}, qs);
                          }
                      }
                  }
                  else if (resource === 'incident') {
                      if (operation === 'create') {
                          const shortDescription = this.getNodeParameter('short_description', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const body = {
                              short_description: shortDescription,
                              ...additionalFields,
                          };
                          const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'POST', '/now/table/incident', body);
                          responseData = response.result;
                      }
                      else if (operation === 'delete') {
                          const id = this.getNodeParameter('id', i);
                          responseData = await GenericFunctions_1.serviceNowApiRequest.call(this, 'DELETE', `/now/table/incident/${id}`);
                          responseData = { success: true };
                      }
                      else if (operation === 'get') {
                          const id = this.getNodeParameter('id', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', `/now/table/incident/${id}`, {}, qs);
                          responseData = response.result;
                      }
                      else if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.sysparm_limit = limit;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/incident', {}, qs);
                              responseData = response.result;
                          }
                          else {
                              responseData = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/incident', {}, qs);
                          }
                      }
                      else if (operation === 'update') {
                          const id = this.getNodeParameter('id', i);
                          const body = this.getNodeParameter('updateFields', i);
                          const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'PATCH', `/now/table/incident/${id}`, body);
                          responseData = response.result;
                      }
                      else {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i });
                      }
                  }
                  else if (resource === 'tableRecord') {
                      if (operation === 'create') {
                          const tableName = this.getNodeParameter('tableName', i);
                          const dataToSend = this.getNodeParameter('dataToSend', i);
                          let body = {};
                          if (dataToSend === 'mapInput') {
                              const inputsToIgnore = this.getNodeParameter('inputsToIgnore', i)
                                  .split(',')
                                  .map((field) => field.trim());
                              body = Object.entries(items[i].json)
                                  .filter(([key]) => !inputsToIgnore.includes(key))
                                  .reduce((obj, [key, val]) => Object.assign(obj, { [key]: val }), {});
                          }
                          else if (dataToSend === 'columns') {
                              const fieldsToSend = this.getNodeParameter('fieldsToSend', i);
                              body = fieldsToSend.field.reduce((obj, field) => {
                                  obj[field.column] = field.value;
                                  return obj;
                              }, {});
                          }
                          const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'POST', `/now/table/${tableName}`, body);
                          responseData = response.result;
                      }
                      else if (operation === 'delete') {
                          const tableName = this.getNodeParameter('tableName', i);
                          const id = this.getNodeParameter('id', i);
                          responseData = await GenericFunctions_1.serviceNowApiRequest.call(this, 'DELETE', `/now/table/${tableName}/${id}`);
                          responseData = { success: true };
                      }
                      else if (operation === 'get') {
                          const tableName = this.getNodeParameter('tableName', i);
                          const id = this.getNodeParameter('id', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', `/now/table/${tableName}/${id}`, {}, qs);
                          responseData = response.result;
                      }
                      else if (operation === 'getAll') {
                          const tableName = this.getNodeParameter('tableName', i);
                          const returnAll = this.getNodeParameter('returnAll', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.sysparm_limit = limit;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', `/now/table/${tableName}`, {}, qs);
                              responseData = response.result;
                          }
                          else {
                              responseData = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', `/now/table/${tableName}`, {}, qs);
                          }
                      }
                      else if (operation === 'update') {
                          const tableName = this.getNodeParameter('tableName', i);
                          const id = this.getNodeParameter('id', i);
                          const dataToSend = this.getNodeParameter('dataToSend', i);
                          let body = {};
                          if (dataToSend === 'mapInput') {
                              const inputsToIgnore = this.getNodeParameter('inputsToIgnore', i)
                                  .split(',')
                                  .map((field) => field.trim());
                              body = Object.entries(items[i].json)
                                  .filter(([key]) => !inputsToIgnore.includes(key))
                                  .reduce((obj, [key, val]) => Object.assign(obj, { [key]: val }), {});
                          }
                          else if (dataToSend === 'columns') {
                              const fieldsToSend = this.getNodeParameter('fieldsToSend', i);
                              body = fieldsToSend.field.reduce((obj, field) => {
                                  obj[field.column] = field.value;
                                  return obj;
                              }, {});
                          }
                          const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'PATCH', `/now/table/${tableName}/${id}`, body);
                          responseData = response.result;
                      }
                      else {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i });
                      }
                  }
                  else if (resource === 'user') {
                      if (operation === 'create') {
                          const body = this.getNodeParameter('additionalFields', i);
                          const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'POST', '/now/table/sys_user', body);
                          responseData = response.result;
                      }
                      else if (operation === 'delete') {
                          const id = this.getNodeParameter('id', i);
                          responseData = await GenericFunctions_1.serviceNowApiRequest.call(this, 'DELETE', `/now/table/sys_user/${id}`);
                          responseData = { success: true };
                      }
                      else if (operation === 'get') {
                          const getOption = this.getNodeParameter('getOption', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          if (getOption === 'id') {
                              const id = this.getNodeParameter('id', i);
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', `/now/table/sys_user/${id}`, {}, qs);
                              responseData = response.result;
                          }
                          else {
                              const userName = this.getNodeParameter('user_name', i);
                              qs.sysparm_query = `user_name=${userName}`;
                              qs.sysparm_limit = 1;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/sys_user', {}, qs);
                              responseData = response.result;
                          }
                      }
                      else if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.sysparm_limit = limit;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/sys_user', {}, qs);
                              responseData = response.result;
                          }
                          else {
                              responseData = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_user', {}, qs);
                          }
                      }
                      else if (operation === 'update') {
                          const id = this.getNodeParameter('id', i);
                          const body = this.getNodeParameter('updateFields', i);
                          const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'PATCH', `/now/table/sys_user/${id}`, body);
                          responseData = response.result;
                      }
                      else {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i });
                      }
                  }
                  else if (resource === 'userGroup') {
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.sysparm_limit = limit;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/sys_user_group', {}, qs);
                              responseData = response.result;
                          }
                          else {
                              responseData = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_user_group', {}, qs);
                          }
                      }
                      else {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i });
                      }
                  }
                  else if (resource === 'userRole') {
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.sysparm_limit = limit;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/sys_user_role', {}, qs);
                              responseData = response.result;
                          }
                          else {
                              responseData = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_user_role', {}, qs);
                          }
                      }
                      else {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i });
                      }
                  }
                  else {
                      throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, {
                          itemIndex: i,
                      });
                  }
              }
              catch (error) {
                  if (this.continueOnFail()) {
                      const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                      returnData.push(...executionErrorData);
                      continue;
                  }
                  throw error;
              }
              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
              returnData.push(...executionData);
          }
          if (resource === 'attachment') {
              if (operation === 'get' || operation === 'getAll') {
                  return [returnData];
              }
          }
          return [returnData];
      }
  }
  exports.ServiceNow = ServiceNow;
  //# sourceMappingURL=ServiceNow.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: ServiceNow credentials
  description: Documentation for ServiceNow credentials. Use these credentials to authenticate ServiceNow in n8n, a workflow automation platform.
  contentType: [integration, reference]
  ---

  # ServiceNow credentials

  You can use these credentials to authenticate the following nodes:

  - [ServiceNow](/integrations/builtin/app-nodes/n8n-nodes-base.servicenow.md)

  ## Prerequisites

  Create a [ServiceNow](https://developer.servicenow.com/dev.do#!/reference){:target=_blank .external-link} developer account.

  ## Supported authentication methods

  - Basic auth
  - OAuth2

  ## Related resources

  Refer to [ServiceNow's API documentation](https://developer.servicenow.com/dev.do#!/reference/api/washingtondc/rest/){:target=_blank .external-link} for more information about the service.

  ## Using basic auth

  To configure this credential, you'll need:

  - A **User** name: Enter your ServiceNow username.
  - A **Password**: Enter your ServiceNow password.
  - A **Subdomain**: The subdomain for your servicenow instance is in your instance URL: `https://<subdomain>.service-now.com/`. For example, if the full URL is `https://dev99890.service-now.com`, then the subdomain is `dev99890`.

  ## Using OAuth2

  To configure this credential, you'll need:

  - A **Client ID**: Generated once you register a new app.
  - A **Client Secret**: Generated once you register a new app.
  - A **Subdomain**: The subdomain for your servicenow instance is in your instance URL: `https://<subdomain>.service-now.com/`. For example, if the full URL is `https://dev99890.service-now.com`, then the subdomain is `dev99890`.

  To generate your **Client ID** and **Client Secret**, register a new app in **System OAuth > Application Registry > New > Create an OAuth API endpoint for external clients**. Use these settings for your app:

  - Copy the **Client ID** and add it to your n8n credential.
  - Enter a **Client Secret** or leave it blank to automatically generate a random secret. Add this secret to your n8n credential.
  - Copy the n8n **OAuth Redirect URL** and add it as a **Redirect URL**.

  Refer to [How to setup OAuth2 authentication for RESTMessageV2 integrations](https://www.servicenow.com/community/in-other-news/how-to-setup-oauth2-authentication-for-restmessagev2/ba-p/2271823){:target=_blank .external-link} for more information.

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"d1eeef21-6e1b-4840-95de-af76c8d7464a","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"bfba336e62f7682c729446a30a6db90061562fe453c21b85a735f63ad9201b94"}}


node_type: n8n-nodes-base.Set
name: Set
display_name: Set
description: Add or edit fields on an input item and optionally remove other fields
category: Other
code_hash: 4414ad216090aa4ae629fc2ed5ae175c48bde7392d1133b82f472edcd1620065
documentation_url: https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.comparedatasets
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
extracted_at: 2025-06-08 08:05:29
updated_at: 2025-06-08 08:05:29
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.Set = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const SetV1_node_1 = require("./v1/SetV1.node");
  const SetV2_node_1 = require("./v2/SetV2.node");
  class Set extends n8n_workflow_1.VersionedNodeType {
      constructor() {
          const baseDescription = {
              displayName: 'Set',
              name: 'set',
              icon: 'fa:pen',
              group: ['input'],
              description: 'Add or edit fields on an input item and optionally remove other fields',
              defaultVersion: 3.2,
          };
          const nodeVersions = {
              1: new SetV1_node_1.SetV1(baseDescription),
              2: new SetV1_node_1.SetV1(baseDescription),
              3: new SetV2_node_1.SetV2(baseDescription),
              3.1: new SetV2_node_1.SetV2(baseDescription),
              3.2: new SetV2_node_1.SetV2(baseDescription),
          };
          super(nodeVersions, baseDescription);
      }
  }
  exports.Set = Set;
  //# sourceMappingURL=Set.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Compare Datasets
  description: Documentation for the Compare Datasets node in n8n, a workflow automation platform. Includes guidance on usage, and links to examples.
  contentType: [integration, reference]
  priority: high
  ---

  # Compare Datasets

  The Compare Datasets node helps you compare data from two input streams.

  ## Node parameters

  1. Decide which fields to compare. In **Input A Field**, enter the name of the field you want to use from input stream A. In **Input B Field**, enter the name of the field you want to use from input stream B. 
  2. **Optional**: You can compare by multiple fields. Select **Add Fields to Match** to set up more comparisons.
  3. Choose how to handle differences between the datasets. In **When There Are Differences**, select one of the following:
  	* **Use Input A Version** to treat input stream A as the source of truth.
  	* **Use Input B Version** to treat input stream B as the source of truth.
  	* **Use a Mix of Versions** to use different inputs for different fields.
  		* Use **Prefer** to select either **Input A Version** or **Input B Version** as the main source of truth.
  		* Enter input fields that are exceptions to **For Everything Except** to pull from the other input source. To add multiple input fields, enter a comma-separated list.
  	* **Include Both Versions** to include both input streams in the output, which may make the structure more complex.
  4. Decide whether to use **Fuzzy Compare**. When turned on, the comparison will tolerate small type differences when comparing fields. For example, the number 3 and the string `3` are treated as the same with **Fuzzy Compare** turned on, but wouldn't be treated the same with it turned off.

  ## Understand item comparison

  Item comparison is a two stage process:

  1. n8n checks if the values of the fields you selected to compare match across both inputs.
  2. If the fields to compare match, n8n then compares all fields within the items, to determine if the items are the same or different.

  ## Node options

  Use the node **Options** to refine your comparison or tweak comparison behavior.

  ### Fields to Skip Comparing

  Enter field names that you want to ignore in the comparison.

  For example, if you compare the two datasets below using `person.language` as the **Fields to Match**, n8n returns them as different. If you add `person.name` to **Fields to Skip Comparing**, n8n returns them as matching.

  ```json
  	// Input 1
  	[
  		{
  			"person":
  			{
  				"name":	"Stefan",
  				"language":	"de"
  			}
  		},
  		{
  			"person":
  			{
  				"name":	"Jim",
  				"language":	"en"
  			}
  		},
  		{
  			"person":
  			{
  				"name":	"Hans",
  				"language":	"de"
  			}
  		}
  	]
  	// Input 2
  		[
  		{
  			"person":
  			{
  				"name":	"Sara",
  				"language":	"de"
  			}
  		},
  		{
  			"person":
  			{
  				"name":	"Jane",
  				"language":	"en"
  			}
  		},
  		{
  			"person":
  			{
  				"name":	"Harriet",
  				"language":	"de"
  			}
  		}
  	]
  ```

  ### Disable Dot Notation

  Whether to disallow referencing child fields using `parent.child` in the field name (turned on) or allow it (turned off, default).

  ### Multiple Matches

  Choose how to handle duplicate data. The default is **Include All Matches**. You can choose **Include First Match Only**.

  For example, given these two datasets:
  ```json
  	// Input 1
  	[
  		{
  			"fruit": {
  				"type": "apple",
  				"color": "red"
  			}
  		},
  				{
  			"fruit": {
  				"type": "apple",
  				"color": "red"
  			}
  		},
  				{
  			"fruit": {
  				"type": "banana",
  				"color": "yellow"
  			}
  		}
  	]
  	// Input 2
  	[
  		{
  			"fruit": {
  				"type": "apple",
  				"color": "red"
  			}
  		},
  				{
  			"fruit": {
  				"type": "apple",
  				"color": "red"
  			}
  		},
  				{
  			"fruit": {
  				"type": "banana",
  				"color": "yellow"
  			}
  		}
  	]
  ```

  n8n returns three items in the **Same Branch** tab. The data is the same in both branches.

  If you select **Include First Match Only**, n8n returns two items, in the **Same Branch** tab. The data is the same in both branches, but n8n only returns the first occurrence of the matching "apple" items.


  ## Understand the output

  There are four output options:

  * **In A only Branch**: Contains data that occurs only in the first input.
  * **Same Branch**: Contains data that's the same in both inputs.
  * **Different Branch**: Contains data that's different between inputs.
  * **In B only Branch**: Contains data that occurs only in the second output.

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'compare-datasets') ]]

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"db5c65c8-467a-41ea-8980-a7ddba0ef4f0","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"782614b5c96012ffa167170711e32071dbfecf46e93b2feb89e27e353c7a51e3"}}


node_type: n8n-nodes-base.Shopify
name: Shopify
display_name: Shopify
description: Consume Shopify API
category: Other
code_hash: c9006b14af5d35b4e773b5812c0f324f95620663fb6b23c928b1c58ccc43a99c
documentation_url: https://docs.n8n.io/integrations/builtin/credentials/shopify
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
extracted_at: 2025-06-08 08:05:29
updated_at: 2025-06-08 08:05:29
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.Shopify = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const GenericFunctions_1 = require("./GenericFunctions");
  const OrderDescription_1 = require("./OrderDescription");
  const ProductDescription_1 = require("./ProductDescription");
  class Shopify {
      constructor() {
          this.description = {
              displayName: 'Shopify',
              name: 'shopify',
              icon: 'file:shopify.svg',
              group: ['output'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
              description: 'Consume Shopify API',
              defaults: {
                  name: 'Shopify',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'shopifyApi',
                      required: true,
                      displayOptions: {
                          show: {
                              authentication: ['apiKey'],
                          },
                      },
                  },
                  {
                      name: 'shopifyAccessTokenApi',
                      required: true,
                      displayOptions: {
                          show: {
                              authentication: ['accessToken'],
                          },
                      },
                  },
                  {
                      name: 'shopifyOAuth2Api',
                      required: true,
                      displayOptions: {
                          show: {
                              authentication: ['oAuth2'],
                          },
                      },
                  },
              ],
              properties: [
                  {
                      displayName: 'Authentication',
                      name: 'authentication',
                      type: 'options',
                      options: [
                          {
                              name: 'Access Token',
                              value: 'accessToken',
                          },
                          {
                              name: 'OAuth2',
                              value: 'oAuth2',
                          },
                          {
                              name: 'API Key',
                              value: 'apiKey',
                          },
                      ],
                      default: 'apiKey',
                  },
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Order',
                              value: 'order',
                          },
                          {
                              name: 'Product',
                              value: 'product',
                          },
                      ],
                      default: 'order',
                  },
                  ...OrderDescription_1.orderOperations,
                  ...OrderDescription_1.orderFields,
                  ...ProductDescription_1.productOperations,
                  ...ProductDescription_1.productFields,
              ],
          };
          this.methods = {
              loadOptions: {
                  async getProducts() {
                      const returnData = [];
                      const products = await GenericFunctions_1.shopifyApiRequestAllItems.call(this, 'products', 'GET', '/products.json', {}, { fields: 'id,title' });
                      for (const product of products) {
                          const productName = product.title;
                          const productId = product.id;
                          returnData.push({
                              name: productName,
                              value: productId,
                          });
                      }
                      return returnData;
                  },
                  async getLocations() {
                      const returnData = [];
                      const locations = await GenericFunctions_1.shopifyApiRequestAllItems.call(this, 'locations', 'GET', '/locations.json', {}, { fields: 'id,name' });
                      for (const location of locations) {
                          const locationName = location.name;
                          const locationId = location.id;
                          returnData.push({
                              name: locationName,
                              value: locationId,
                          });
                      }
                      return returnData;
                  },
              },
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          const length = items.length;
          let responseData;
          const qs = {};
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          for (let i = 0; i < length; i++) {
              try {
                  if (resource === 'order') {
                      if (operation === 'create') {
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const discount = additionalFields.discountCodesUi;
                          const billing = additionalFields.billingAddressUi;
                          const shipping = additionalFields.shippingAddressUi;
                          const lineItem = this.getNodeParameter('limeItemsUi', i)
                              .lineItemValues;
                          if (lineItem === undefined) {
                              throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'At least one line item has to be added', { itemIndex: i });
                          }
                          const body = {
                              test: true,
                              line_items: (0, GenericFunctions_1.keysToSnakeCase)(lineItem),
                          };
                          if (additionalFields.fulfillmentStatus) {
                              body.fulfillment_status = additionalFields.fulfillmentStatus;
                          }
                          if (additionalFields.inventoryBehaviour) {
                              body.inventory_behaviour = additionalFields.inventoryBehaviour;
                          }
                          if (additionalFields.locationId) {
                              body.location_id = additionalFields.locationId;
                          }
                          if (additionalFields.note) {
                              body.note = additionalFields.note;
                          }
                          if (additionalFields.sendFulfillmentReceipt) {
                              body.send_fulfillment_receipt = additionalFields.sendFulfillmentReceipt;
                          }
                          if (additionalFields.sendReceipt) {
                              body.send_receipt = additionalFields.sendReceipt;
                          }
                          if (additionalFields.sendReceipt) {
                              body.send_receipt = additionalFields.sendReceipt;
                          }
                          if (additionalFields.sourceName) {
                              body.source_name = additionalFields.sourceName;
                          }
                          if (additionalFields.tags) {
                              body.tags = additionalFields.tags;
                          }
                          if (additionalFields.test) {
                              body.test = additionalFields.test;
                          }
                          if (additionalFields.email) {
                              body.email = additionalFields.email;
                          }
                          if (discount) {
                              body.discount_codes = discount.discountCodesValues;
                          }
                          if (billing) {
                              body.billing_address = (0, GenericFunctions_1.keysToSnakeCase)(billing.billingAddressValues)[0];
                          }
                          if (shipping) {
                              body.shipping_address = (0, GenericFunctions_1.keysToSnakeCase)(shipping.shippingAddressValues)[0];
                          }
                          responseData = await GenericFunctions_1.shopifyApiRequest.call(this, 'POST', '/orders.json', {
                              order: body,
                          });
                          responseData = responseData.order;
                      }
                      if (operation === 'delete') {
                          const orderId = this.getNodeParameter('orderId', i);
                          responseData = await GenericFunctions_1.shopifyApiRequest.call(this, 'DELETE', `/orders/${orderId}.json`);
                          responseData = { success: true };
                      }
                      if (operation === 'get') {
                          const orderId = this.getNodeParameter('orderId', i);
                          const options = this.getNodeParameter('options', i);
                          if (options.fields) {
                              qs.fields = options.fields;
                          }
                          responseData = await GenericFunctions_1.shopifyApiRequest.call(this, 'GET', `/orders/${orderId}.json`, {}, qs);
                          responseData = responseData.order;
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          if (options.fields) {
                              qs.fields = options.fields;
                          }
                          if (options.attributionAppId) {
                              qs.attribution_app_id = options.attributionAppId;
                          }
                          if (options.createdAtMin) {
                              qs.created_at_min = options.createdAtMin;
                          }
                          if (options.createdAtMax) {
                              qs.created_at_max = options.createdAtMax;
                          }
                          if (options.updatedAtMax) {
                              qs.updated_at_max = options.updatedAtMax;
                          }
                          if (options.updatedAtMin) {
                              qs.updated_at_min = options.updatedAtMin;
                          }
                          if (options.processedAtMin) {
                              qs.processed_at_min = options.processedAtMin;
                          }
                          if (options.processedAtMax) {
                              qs.processed_at_max = options.processedAtMax;
                          }
                          if (options.sinceId) {
                              qs.since_id = options.sinceId;
                          }
                          if (options.ids) {
                              qs.ids = options.ids;
                          }
                          if (options.status) {
                              qs.status = options.status;
                          }
                          if (options.financialStatus) {
                              qs.financial_status = options.financialStatus;
                          }
                          if (options.fulfillmentStatus) {
                              qs.fulfillment_status = options.fulfillmentStatus;
                          }
                          if (returnAll) {
                              responseData = await GenericFunctions_1.shopifyApiRequestAllItems.call(this, 'orders', 'GET', '/orders.json', {}, qs);
                          }
                          else {
                              qs.limit = this.getNodeParameter('limit', i);
                              responseData = await GenericFunctions_1.shopifyApiRequest.call(this, 'GET', '/orders.json', {}, qs);
                              responseData = responseData.orders;
                          }
                      }
                      if (operation === 'update') {
                          const orderId = this.getNodeParameter('orderId', i);
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const shipping = updateFields.shippingAddressUi;
                          const body = {};
                          if (updateFields.locationId) {
                              body.location_id = updateFields.locationId;
                          }
                          if (updateFields.note) {
                              body.note = updateFields.note;
                          }
                          if (updateFields.sourceName) {
                              body.source_name = updateFields.sourceName;
                          }
                          if (updateFields.tags) {
                              body.tags = updateFields.tags;
                          }
                          if (updateFields.email) {
                              body.email = updateFields.email;
                          }
                          if (shipping) {
                              body.shipping_address = (0, GenericFunctions_1.keysToSnakeCase)(shipping.shippingAddressValues)[0];
                          }
                          responseData = await GenericFunctions_1.shopifyApiRequest.call(this, 'PUT', `/orders/${orderId}.json`, {
                              order: body,
                          });
                          responseData = responseData.order;
                      }
                  }
                  else if (resource === 'product') {
                      const productId = this.getNodeParameter('productId', i, '');
                      let body = {};
                      if (operation === 'create') {
                          const title = this.getNodeParameter('title', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i, {});
                          if (additionalFields.productOptions) {
                              const metadata = additionalFields.productOptions
                                  .option;
                              additionalFields.options = {};
                              for (const data of metadata) {
                                  additionalFields.options[data.name] = data.value;
                              }
                              delete additionalFields.productOptions;
                          }
                          body = additionalFields;
                          body.title = title;
                          responseData = await GenericFunctions_1.shopifyApiRequest.call(this, 'POST', '/products.json', {
                              product: body,
                          });
                          responseData = responseData.product;
                      }
                      if (operation === 'delete') {
                          responseData = await GenericFunctions_1.shopifyApiRequest.call(this, 'DELETE', `/products/${productId}.json`);
                          responseData = { success: true };
                      }
                      if (operation === 'get') {
                          const additionalFields = this.getNodeParameter('additionalFields', i, {});
                          Object.assign(qs, additionalFields);
                          responseData = await GenericFunctions_1.shopifyApiRequest.call(this, 'GET', `/products/${productId}.json`, {}, qs);
                          responseData = responseData.product;
                      }
                      if (operation === 'getAll') {
                          const additionalFields = this.getNodeParameter('additionalFields', i, {});
                          const returnAll = this.getNodeParameter('returnAll', i);
                          Object.assign(qs, additionalFields);
                          if (returnAll) {
                              responseData = await GenericFunctions_1.shopifyApiRequestAllItems.call(this, 'products', 'GET', '/products.json', {}, qs);
                          }
                          else {
                              qs.limit = this.getNodeParameter('limit', i);
                              responseData = await GenericFunctions_1.shopifyApiRequest.call(this, 'GET', '/products.json', {}, qs);
                              responseData = responseData.products;
                          }
                      }
                      if (operation === 'update') {
                          const updateFields = this.getNodeParameter('updateFields', i, {});
                          if (updateFields.productOptions) {
                              const metadata = updateFields.productOptions.option;
                              updateFields.options = {};
                              for (const data of metadata) {
                                  updateFields.options[data.name] = data.value;
                              }
                              delete updateFields.productOptions;
                          }
                          body = updateFields;
                          responseData = await GenericFunctions_1.shopifyApiRequest.call(this, 'PUT', `/products/${productId}.json`, { product: body });
                          responseData = responseData.product;
                      }
                  }
                  const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                  returnData.push(...executionData);
              }
              catch (error) {
                  if (this.continueOnFail()) {
                      const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                      returnData.push(...executionErrorData);
                      continue;
                  }
                  throw error;
              }
          }
          return [returnData];
      }
  }
  exports.Shopify = Shopify;
  //# sourceMappingURL=Shopify.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Shopify credentials
  description: Documentation for Shopify credentials. Use these credentials to authenticate Shopify in n8n, a workflow automation platform.
  contentType: [integration, reference]
  priority: medium
  ---

  # Shopify credentials

  You can use these credentials to authenticate the following nodes with Shopify.

  - [Shopify](/integrations/builtin/app-nodes/n8n-nodes-base.shopify.md)
  - [Shopify Trigger](/integrations/builtin/trigger-nodes/n8n-nodes-base.shopifytrigger.md)

  ## Supported authentication methods

  - Access token (recommended): For private apps/single store use. Can be created by regular admins.
  - OAuth2: For public apps. Must be created by partner accounts.
  - API key: Deprecated.

  ## Related resources

  Refer to [Shopify's authentication documentation](https://shopify.dev/docs/apps/auth){:target=_blank .external-link} for more information about the service.

  ## Using access token

  To configure this credential, you'll need a [Shopify](https://shopify.com/){:target=_blank .external-link} admin account and:

  - Your **Shop Subdomain**
  - An **Access Token**: Generated when you create a custom app.
  - An **APP Secret Key**: Generated when you create a custom app.

  To set up the credential, you'll need to create and install a custom app:

  1. Enter your **Shop Subdomain**.
      - Your subdomain is within the URL: `https://<subdomain>.myshopify.com`. For example, if the full URL is `https://n8n.myshopify.com`, the Shop Subdomain is `n8n`.
  2. In Shopify, go to **Admin > Settings >** [**Apps and sales channels**](https://admin.shopify.com/settings/apps){:target=_blank .external-link}.
  3. Select **Develop apps**.
  4. Select **Create a custom app**.

      /// note | Don't see this option?
      If you don't see this option, your store probably doesn't have custom app development enabled. Refer to [Enable custom app development](#enable-custom-app-development) for more information.
      ///

  5. In the modal window, enter the **App name**.
  6. Select an **App developer**. The app developer can be the store owner or any account with the **Develop apps** permission.
  7. Select **Create app**.
  8. Select **Select scopes**. In the **Admin API access scopes** section, select the API scopes you want for your app.
      - To use all functionality in the [Shopify](/integrations/builtin/app-nodes/n8n-nodes-base.shopify.md) node, add the `read_orders`, `write_orders`, `read_products`, and `write_products` scopes.
      - Refer to [Shopify API Access Scopes](https://shopify.dev/docs/api/usage/access-scopes){:target=_blank .external-link} for more information on the available scopes.
  9. Select **Save**.
  10. Select **Install app**.
  11. In the modal window, select **Install app**.
  12. Open the app's **API Credentials** section.
  13. Copy the **Admin API Access Token**. Enter this in your n8n credential as the **Access Token**.
  14. Copy the **API Secret Key**. Enter this in your n8n credential as the **APP Secret Key**.

  Refer to [Creating a custom app](https://help.shopify.com/en/manual/apps/app-types/custom-apps){:target=_blank .external-link} and [Generate access tokens for custom apps in the Shopify admin](https://shopify.dev/docs/apps/build/authentication-authorization/access-token-types/generate-app-access-tokens-admin){:target=_blank .external-link} for more information on these steps.

  ## Using OAuth2

  To configure this credential, you'll need a [Shopify partner](https://www.shopify.com/partners){:target=_blank .external-link} account and:

  - A **Client ID**: Generated when you create a custom app.
  - A **Client Secret**: Generated when you create a custom app.
  - Your **Shop Subdomain**

  To set up the credential, you'll need to create and install a custom app:

  /// note | Custom app development
  Shopify provides templates for creating new apps. The instructions below only cover the elements necessary to set up your n8n credential. Refer to Shopify's [Build dev docs](https://shopify.dev/docs/apps/build){:target=_blank .external-link} for more information on building apps and working with app templates.
  ///

  1. Open your [Shopify Partner dashboard](https://partners.shopify.com/){:target=_blank .external-link}.
  2. Select **Apps** from the left navigation.
  3. Select **Create app**.
  4. In the **Use Shopify Partners** section, enter an **App name**.
  6. Select **Create app**.
  7. When the app details open, copy the **Client ID**. Enter this in your n8n credential.
  8. Copy the **Client Secret**. Enter this in your n8n credential.
  9. In the left menu, select **Configuration**.
  10. In n8n, copy the **OAuth Redirect URL** and paste it into the **Allowed redirection URL(s)** in the **URLs** section.
  10. In the **URLs** section, enter an **App URL** for your app. The host entered here needs to match the host for the **Allowed redirection URL(s)**, like the base URL for your n8n instance.
  8. Select **Save and release**.
  1. Select **Overview** from the left menu. At this point, you can choose to **Test your app** by installing it to one of your stores, or **Choose distribution** to distribute it publicly.
  1. In n8n, enter the **Shop Subdomain** of the store you installed the app to, either as a test or as a distribution.
      - Your subdomain is within the URL: `https://<subdomain>.myshopify.com`. For example, if the full URL is `https://n8n.myshopify.com`, the Shop Subdomain is `n8n`.

  ## Using API key

  /// warning | Method deprecated
  Shopify no longer generates API keys with passwords. Use the [Access token](#using-access-token) method instead.
  ///

  To configure this credential, you'll need:

  - An **API Key**
  - A **Password**
  - Your **Shop Subdomain**: Your subdomain is within the URL: `https://<subdomain>.myshopify.com`. For example, if the full URL is `https://n8n.myshopify.com`, the Shop Subdomain is `n8n`.
  - _Optional:_ A **Shared Secret**

  ## Common issues

  Here are some common issues setting up the Shopify credential and steps to resolve or troubleshoot them.

  ### Enable custom app development

  If you don't see the option to **Create a custom app**, no one's enabled custom app development for your store.

  To enable custom app development, you must log in either as a store owner or as a user with the **Enable app development** permission:

  1. In Shopify, go to **Admin > Settings >** [**Apps and sales channels**](https://admin.shopify.com/settings/apps){:target=_blank .external-link}.
  2. Select **Develop apps**.
  3. Select **Allow custom app development**.
  4. Read the warning and information provided and select **Allow custom app development**.

  ### Forbidden credentials error

  <!-- vale off -->
  If you get a **Couldn't connect with these settings / Forbidden - perhaps check your credentials** warning when you test the credentials, this may be due to your app's [access scope](https://shopify.dev/docs/api/usage/access-scopes){:target=_blank .external-link} dependencies. For example, the `read_orders` scope also requires `read_products` scope. Review the scopes you have assigned and the action you're trying to complete.
  <!-- vale on -->

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"f88f3d57-cc7d-411d-a8cd-cdbe91d72ff3","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"28f4974993480bdadf4df4663434ba4ebfc20f82fdc2a079929d31694755f7bd"}}


