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.2 KB
Raw Blame
import { createAction } from '@activepieces/pieces-framework';
import { BASE_URL, spaceIdDropdown, postIdDropdown } from '../common';
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
import { circleAuth } from '../common/auth';
import { PostDetails } from '../common/types';

export const getPostDetailsAction = createAction({
	auth: circleAuth,
	name: 'get_post_details',
	classification: 'READ',
	displayName: 'Get Post Details',
	description: 'Retrieves the complete details of a specific post.',
	audience: 'both',
	aiMetadata: { description: 'Retrieves the full details of a single Circle post by its post ID. Use to read a known post\'s content and metadata. Read-only and idempotent.', idempotent: true },
	props: {
		space_id: spaceIdDropdown,
		post_id: postIdDropdown,
	},
	async run(context) {
		const { post_id } = context.propsValue;

		if (post_id === undefined) {
			throw new Error('Post ID is undefined, but it is a required field.');
		}

		const response = await httpClient.sendRequest<PostDetails>({
			method: HttpMethod.GET,
			url: `${BASE_URL}/posts/${post_id}`,
			headers: {
				Authorization: `Bearer ${context.auth.secret_text}`,
				'Content-Type': 'application/json',
			},
		});
		return response.body;
	},
});