Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.3 KB
Raw Blame
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
import { createAction, OAuth2PropertyValue, Property } from '@activepieces/pieces-framework';
import { trueLayerCommon } from '../../common';

export const getConstraints = createAction({
  auth: trueLayerCommon.auth,
  name: 'get-constraints',
  classification: 'READ',
  displayName: 'Get Mandate Constraints',
  description: 'Retrieve the constraints defined on the mandate, as well as the current utilization of those constraints within the periods.',
  audience: 'both',
  aiMetadata: { description: 'Look up the spending constraints set on a mandate and how much has already been used within each period. Use to check remaining headroom or limits before initiating a payment under the mandate. Read-only and safe to repeat.', idempotent: true },
  props: {
    id: Property.ShortText({
      displayName: 'Mandate ID',
      description: 'The ID of the mandate to retrieve the constraints for.',
      required: true,
    }),
  },
  run: async (ctx) => {
    const response = await httpClient.sendRequest({
      method: HttpMethod.GET,
      url: `${trueLayerCommon.baseUrl}/v3/mandates/${ctx.propsValue.id}/constraints`,
      headers: {
        Authorization: `Bearer ${(ctx.auth as OAuth2PropertyValue).access_token}`,
      },
    })
    return response.body

  },
});