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 {
  AuthenticationResponse,
  PlatformResponse,
  UpdatePlatformRequestBody,
} from '@activepieces/shared';

import { api } from '@/lib/api';
import { authenticationSession } from '@/lib/authentication-session';

export const platformApi = {
  createPlatform({ name }: { name: string }) {
    return api.post<AuthenticationResponse>('/v1/platforms', { name });
  },
  deletePlatform() {
    return api.delete<void>(
      `/v1/platforms/${authenticationSession.getPlatformId()}`,
    );
  },
  getCurrentPlatform() {
    const platformId = authenticationSession.getPlatformId();
    if (!platformId) {
      throw Error('No platform id found');
    }
    return api.get<PlatformResponse>(`/v1/platforms/${platformId}`);
  },

  activateLicenseKey(licenseKey: string) {
    return api.post<void>(`/v1/platform-billing/activate`, {
      licenseKey,
    });
  },

  update(req: UpdatePlatformRequestBody, platformId: string) {
    return api.post<PlatformResponse>(`/v1/platforms/${platformId}`, req);
  },
  updateWithFormData(formdata: FormData, platformId: string) {
    return api.post<PlatformResponse>(
      `/v1/platforms/${platformId}`,
      formdata,
      {},
      {
        'Content-Type': 'multipart/form-data',
      },
    );
  },
};