Class AiPlansResource

Hierarchy

  • Resource
    • AiPlansResource

Constructors

Methods

  • Archiva el plan: sale del listado y pasa al de archivados (list(..., { archived: true })).

    Es sólo visibilidad. No toca ninguna publicación —lo que estuviera programado sigue publicándose—, no devuelve créditos y no cancela nada, así que vale en CUALQUIER estado, generating incluido: no interrumpe al job. Se deshace con unarchive.

    Es lo que se busca casi siempre que uno piensa en "quitar" un plan: remove se lleva por delante las publicaciones que aún no han salido, y esto no.

    Parameters

    • idClient: string
    • idOrganization: string
    • idAiPlan: string
    • options: RequestOptions = {}

    Returns Promise<
        {
            _id: string;
            accounts: string[];
            archived_date?: string;
            attempts: number;
            creation_date: string;
            credits_spent: number;
            destinations?: {
                destination: {
                    id?: string;
                    name?: string;
                    section_id?: string;
                    section_name?: string;
                };
                id_account: string;
            }[];
            error?: {
                code: number;
                data?: { [key: string]: unknown };
                message: string;
            };
            generation_end_date?: string;
            id_client: string;
            id_organization: string;
            keycloak_identifier?: string;
            options: {
                allow_images: boolean;
                gallery_uploads: string[];
                language: string;
                link?: string;
                max_images?: number;
                publish_days: number[];
                shared: boolean;
                timezone: string;
                tone?: string;
                use_organization_context: boolean;
                week_start: string;
            };
            orchestrator_result?: Record<string, never>;
            organization_context?: {
                audience?: string;
                avoid?: string;
                blog_url?: string;
                brand_name?: string;
                default_tone?: string;
                description?: string;
                keywords?: string[];
                notes?: string;
                products?: string;
                sector?: string;
                shop_url?: string;
                social_urls?: string[];
                value_proposition?: string;
                website?: string;
            };
            prompt: string;
            publications: (
                | string
                | {
                    _id: string;
                    ai_generated?: { image: boolean; text: boolean };
                    creation_date: string;
                    destination?: {
                        id?: string;
                        name?: string;
                        section_id?: string;
                        section_name?: string;
                    };
                    engagement_base?: "reach"
                    | "impressions"
                    | "followers";
                    external_identifier?: string;
                    extra_data?: { [key: string]: unknown };
                    files: {
                        _id: string;
                        ai_generated?: {
                            generated_at: string;
                            id_ai_plan?: string;
                            model: string;
                            provider: string;
                        };
                        cover_image?: { _id: string; ai_generated?: { generated_at: string; id_ai_plan?: string; model: string; provider: string; }; cover_image?: ...; cover_offset?: number; creation_date: string; file_externals: { external_identifier: string; external_url: string; social_network: "facebook" | ... 12 more ... | "pinterest"; }[]; ... 6 m...;
                        cover_offset?: number;
                        creation_date: string;
                        file_externals: {
                            external_identifier: string;
                            external_url: string;
                            social_network: | "facebook"
                            | "instagram"
                            | "linkedin"
                            | "tiktok"
                            | "twitter"
                            | "whatsapp"
                            | "youtube"
                            | "google_business"
                            | "bluesky"
                            | "discord"
                            | "telegram"
                            | "threads"
                            | "slack"
                            | "pinterest";
                        }[];
                        file_format: "mp4"
                        | "jpeg"
                        | "gif"
                        | "png"
                        | "jpg";
                        file_properties: {
                            allowed_social_networks: string[];
                            aspect_ratio: { text: string; value: number };
                            duration: number;
                            height: number;
                            size_in_bytes: number;
                            width: number;
                        };
                        file_type: "video"
                        | "image";
                        id_organization: string;
                        is_temporal: boolean;
                        name: string;
                        public_path: string;
                    }[];
                    id_account: | string
                    | {
                        _id: string;
                        creation_date: string;
                        error_code: number;
                        extra_data?: { is_personal_profile?: (...)
                        | (...)
                        | (...) } & { [key: string]: unknown };
                        followers_count?: number;
                        id_client: string;
                        id_organization: string;
                        image?: string;
                        name: string;
                        next_comments_update?: string;
                        next_stats_update?: string;
                        private_message_link?: string;
                        social_network:
                            | "facebook"
                            | "instagram"
                            | "linkedin"
                            | "tiktok"
                            | "twitter"
                            | "whatsapp"
                            | "youtube"
                            | "google_business"
                            | "bluesky"
                            | "discord"
                            | "telegram"
                            | "threads"
                            | "slack"
                            | "pinterest";
                        username?: string;
                    };
                    id_integration?: string;
                    id_organization: string;
                    link?: string;
                    made_for_kids?: boolean;
                    metrics?: {
                        clicks?: number;
                        comments?: number;
                        engagement?: number;
                        followers?: number;
                        followers_gained?: number;
                        impressions?: number;
                        likes?: number;
                        profile_views?: number;
                        reach?: number;
                        saves?: number;
                        shares?: number;
                        video_views?: number;
                    };
                    name?: string;
                    next_stats_update?: string;
                    pending_publish?: {
                        data?: { [key: string]: unknown };
                        deadline?: string;
                        next_check?: string;
                        temp_keys?: string[];
                    };
                    publication_errors: {
                        code: number;
                        data?: { [key: string]: unknown };
                        message: string;
                    }[];
                    publication_type: | "profile"
                    | "page"
                    | "group"
                    | "reels"
                    | "stories"
                    | "message";
                    publication_warnings?: {
                        code: number;
                        data?: { [key: string]: unknown };
                        message: string;
                    }[];
                    publish_date?: string;
                    reply_control?: | "everyone"
                    | "accounts_you_follow"
                    | "mentioned_only"
                    | "followers_only";
                    retries: number;
                    social_network: | "facebook"
                    | "instagram"
                    | "linkedin"
                    | "tiktok"
                    | "twitter"
                    | "whatsapp"
                    | "youtube"
                    | "google_business"
                    | "bluesky"
                    | "discord"
                    | "telegram"
                    | "threads"
                    | "slack"
                    | "pinterest";
                    state: "ready"
                    | "withErrors"
                    | "sended"
                    | "draft"
                    | "publishing";
                    statistics?: {
                        angers?: number;
                        bookmarks?: number;
                        clicks?: number;
                        comments?: number;
                        engagement?: number;
                        follows?: number;
                        hahas?: number;
                        impressions?: number;
                        likes?: number;
                        loves?: number;
                        negative_feedback?: number;
                        outbound_clicks?: number;
                        page_likes?: number;
                        pin_clicks?: number;
                        playback_0_count?: number;
                        playback_100_count?: number;
                        playback_25_count?: number;
                        playback_50_count?: number;
                        playback_75_count?: number;
                        profile_activity?: number;
                        profile_visits?: number;
                        quotes?: number;
                        reach?: number;
                        reactions?: number;
                        reactions_by_emoji?: { [key: string]: number };
                        replys?: number;
                        retwets?: number;
                        saved?: number;
                        saves?: number;
                        share?: number;
                        shareMentions?: number;
                        shares?: number;
                        sorrys?: number;
                        url_link_clicks?: number;
                        user_profile_clicks?: number;
                        video_views?: number;
                        views?: number;
                        wows?: number;
                    };
                    stats_updated_date?: string;
                    text?: string;
                    title?: string;
                    url?: string;
                    visibility?: "public"
                    | "unlisted"
                    | "private";
                }
            )[];
            source?: {
                event?: { date?: string; name?: string };
                id_account_catalog?: string;
                id_integration_catalog?: string;
                images?: { description?: string; id_upload?: string }[];
                products?: {
                    description?: string;
                    external_id?: string;
                    id_upload?: string;
                    name?: string;
                    permalink?: string;
                    price?: string;
                }[];
                text?: string;
                url?: string;
            };
            state: | "pending"
            | "generating"
            | "generated"
            | "validated"
            | "failed"
            | "cancelled";
            template?: | "standard"
            | "from_images"
            | "from_text"
            | "from_catalog"
            | "campaign";
            warnings?: {
                code: number;
                data?: { [key: string]: unknown };
                message: string;
            }[];
        },
    >

  • Encola un plan. No devuelve publicaciones: devuelve el plan en pending y el presupuesto que se calculó para aceptarlo.

    Falla ANTES de gastar nada si no hay créditos para el coste imprescindible (941), si no queda cupo de publicaciones (924), si alguna cuenta no publica —WhatsApp, Google Business— (942), o si con los días elegidos no queda ningún hueco futuro en la semana (2108).

    const { ai_plan, estimate } = await pv.aiPlans.create(clientId, orgId, {
    prompt: "Pan de masa madre, horno de leña, barrio",
    accounts: [accountId],
    options: { publish_days: [1, 3, 5], timezone: "Europe/Madrid" },
    });

    Con plantilla van además template y su source, que se valida aquí: la URL se descarga y el catálogo se lee dentro de esta llamada, así que sus errores llegan mientras el usuario sigue delante — 2111 (plantilla que no existe), 2112 (fuente que no cuadra con la plantilla), 2113 (la URL no se pudo leer), 2114 (la URL apunta a una dirección no pública), 2115 (la cuenta no tiene un catálogo utilizable) y 2116 (la fuente se quedó sin unidades).

    await pv.aiPlans.create(clientId, orgId, {
    prompt: "Nuestra carta de otoño",
    accounts: [accountId],
    template: "from_images",
    source: {
    images: [
    { id_upload: primera, description: "Masa reposando en el banco" },
    { id_upload: segunda, description: "La hogaza saliendo del horno" },
    ],
    },
    });

    El orden de images y de products es la historia: el orquestador se queda con la posición de cada uno, así que la foto 3 puede ser el "antes" y la 7 el "después".

    Con Pinterest en el plan, el tablero de cada cuenta va en destinations y es obligatorio (2118, con todas las cuentas que fallan). Y un plan que dejaría pins sin imagen se rechaza aquí con el 2119, antes de gastar un crédito. Ver AiPlanCreateRequest.

    await pv.aiPlans.create(clientId, orgId, {
    prompt: "Recetas de otoño",
    accounts: [pinterestId, instagramId],
    destinations: [{ id_account: pinterestId, destination: { id: board.id, name: board.name } }],
    options: { link: "https://panaderia.example/otono" },
    });

    Parameters

    • idClient: string
    • idOrganization: string
    • body: {
          accounts: string[];
          destinations?: {
              destination: {
                  id?: string;
                  name?: string;
                  section_id?: string;
                  section_name?: string;
              };
              id_account: string;
          }[];
          options?: {
              allow_images?: boolean;
              gallery_uploads?: string[];
              language?: string;
              link?: string;
              max_images?: number;
              publish_days?: number[];
              shared?: boolean;
              timezone?: string;
              tone?: string;
              use_organization_context?: boolean;
              week_start?: string;
          };
          prompt: string;
          source?: {
              event_date?: string;
              event_name?: string;
              id_account_catalog?: string;
              id_integration_catalog?: string;
              images?: { description: string; id_upload: string }[];
              product_catalog_id?: string;
              products?: string[];
              text?: string;
              url?: string;
          };
          template?: | "standard"
          | "from_images"
          | "from_text"
          | "from_catalog"
          | "campaign";
      }
      • accounts: string[]

        Account ids (belonging to the organization) to generate the plan for. Not every network fits every template: leave out the ones in the template's unsupported_networks (GET /planner_templates), or the plan is refused with 2120.

      • Optionaldestinations?: {
            destination: {
                id?: string;
                name?: string;
                section_id?: string;
                section_name?: string;
            };
            id_account: string;
        }[]

        Where each account publishes, for the networks that answer destinations: true in GET /social_capabilities — today pinterest alone, where it is the board of every pin of that account.

        **On Pinterest it is required, one entry per Pinterest account of the plan.** A plan without it — or with a board id that is not a string of digits — is rejected with **2118**, listing EVERY account that fails in `data.accounts[]` with the same `reason` as the publication's 987 (`missing`, `invalid_id`, `invalid_section_id`), so your UI can mark them all at once. Without this check the plan would be created, charged, and leave a week of drafts in `withErrors` with the 987.
        
        Entries for accounts on networks without destinations are dropped, not rejected. The board is **not** checked against Pinterest at creation — that would make creating a plan depend on Pinterest answering; a board that does not exist fails when the pin is published. Read the account's boards with `GET /organizations/{id_organization}/accounts/{id_account}/destinations`.
        
      • Optionaloptions?: {
            allow_images?: boolean;
            gallery_uploads?: string[];
            language?: string;
            link?: string;
            max_images?: number;
            publish_days?: number[];
            shared?: boolean;
            timezone?: string;
            tone?: string;
            use_organization_context?: boolean;
            week_start?: string;
        }
        • Optionalallow_images?: boolean

          Whether images may be generated. Each image costs 70 AI credits. Optional; defaults to true. Forced to false when the template does not generate images (generates_images: false), where the picture comes from the source and costs nothing.

        • Optionalgallery_uploads?: string[]

          Upload ids from the organization's gallery used as visual reference for the generated images. They are references for the images the model GENERATES, so a template that does not generate them does not accept them either (allows_gallery): sending them to from_images or from_catalog is a 2106.

        • Optionallanguage?: string

          Language of the generated texts. Optional; defaults to "es".

        • Optionallink?: string

          The destination link of the plan's publications — the pin's link, the same for every publication of the plan. Optional: a pin without a link is legitimate, it just takes nobody anywhere. On from_catalog, each pin leads to its product's page (permalink) when this is absent; when it is present, it wins.

          It only reaches the publications of the networks that answer `link: true` in `GET /social_capabilities` (today `pinterest`); with none of them in the plan it is dropped. With one, it is validated **at creation**: a URL Pinterest would reject is a **994** now (`data.reason` `invalid_url` or `too_long`), not a week of pins failing at publish time.
          
        • Optionalmax_images?: number

          Optional cap on the number of images; the credit budget may reduce it further.

        • Optionalpublish_days?: number[]

          Days of the week the plan publishes on, in ISO 8601 numbering (1 = Monday ... 7 = Sunday). Defaults to the whole week. There is still at most ONE publication per day and account, so this is what bounds the size and the cost of the plan: the number of generated posts is (selected days x accounts). Must be a non-empty array of unique integers between 1 and 7, or the request is rejected with 2106. The 7-day window starts at week_start, so each ISO day appears exactly once: with a week_start in mid-week, day 1 (Monday) is the FOLLOWING Monday. If the selected days leave no future slot at all, the request is rejected with 2108. Optional; defaults to [1,2,3,4,5,6,7].

        • Optionalshared?: boolean

          Generate ONE piece of content per day and replicate it across every account, each scheduled at the best hour for ITS network, instead of one publication per account and day. Cheaper — one text and one image per day — and it caps images at 7. Optional; defaults to false. Not every template accepts it (allows_shared in GET /planner_templates): from_images and from_catalog do not, because each of their publications carries a photo of its own, and sending true to them is rejected with 2106.

        • Optionaltimezone?: string

          IANA timezone for the optimal publish slots (typically the user's browser timezone). publish_date is stored in UTC. Optional; defaults to "Europe/Madrid".

        • Optionaltone?: string

          Optional tone (e.g. 'cercano', 'profesional') passed to the prompt.

        • Optionaluse_organization_context?: boolean

          Use the organization's brand context in the prompts. It is copied into the plan as a SNAPSHOT when the plan is created, so a retry or a regeneration uses the context the plan was asked with even if the configuration changed meanwhile. Optional; defaults to true.

        • Optionalweek_start?: string

          Format: date-time

          Start of the week to plan (slots are generated between this date and +7 days). Defaults to now.

      • prompt: string

        Theme prompt written by the user.

      • Optionalsource?: {
            event_date?: string;
            event_name?: string;
            id_account_catalog?: string;
            id_integration_catalog?: string;
            images?: { description: string; id_upload: string }[];
            product_catalog_id?: string;
            products?: string[];
            text?: string;
            url?: string;
        }

        The source itself. Which fields it carries depends on template. Required for every template except standard, and validated at creation — 2112, 2113, 2114, 2115, 2116 or a store's own errors (2200, 2207-2214) come back while the user is still there.

        • Optionalevent_date?: string

          Format: date

          campaign. The day of the event. Send a calendar day, YYYY-MM-DD — never an ISO instant. A bare date is read in the plan's options.timezone, which is the whole point: 2026-09-15T00:00:00Z is midnight UTC, that is the 14th in the afternoon in New York — a whole day off in a countdown, for half of America, with no error anywhere. It cannot fall before the plan week (options.week_start) nor more than 60 days after it (2112). And it does not move publish_days: if the event lands on a day you did not choose, the plan respects your choice and it is up to you to say so.

        • Optionalevent_name?: string

          campaign. What the countdown is towards ("Rebajas de verano", "Apertura del local"). Over 120 characters it is rejected, not truncated: a name cut mid-word would come out that way in all seven publications, and whatever else needs saying goes in prompt.

        • Optionalid_account_catalog?: string

          from_catalog, from a Meta catalogue. Which account's catalogue the products come from. It has to belong to the organization (2103) and be on a network that supports products (2115). It only chooses the catalogue: the publications still go to every account in accounts — a LinkedIn account can publish a product from a Facebook catalogue. Exclusive with id_integration_catalog (both at once is a 2112).

        • Optionalid_integration_catalog?: string

          from_catalog, from a connected store. An integration of the organization whose provider has catalog: true (a WooCommerce store), enabled; another organization's is a 2200, without confirming it exists. The products are its external_ids, from GET .../integrations/{id_integration}/products. Like the account, it only chooses the catalogue: the publications go to every account in accounts. Exclusive with id_account_catalog.

        • Optionalimages?: { description: string; id_upload: string }[]

          from_images. Your own photos, each with its own description, in the order that tells the story: the orchestrator picks one per publication and keeps its position in source_index, so photo 3 can be the "before" and photo 7 the "after". Up to 20 (max_source_items), and each one has to be an image upload of this organization (806 otherwise).

        • Optionalproduct_catalog_id?: string

          from_catalog with id_account_catalog only. The catalogue itself, as the network identifies it: an account can have several catalogues, a store is one.

        • Optionalproducts?: string[]

          from_catalog. Ids of the chosen products, in the order they should tell the week. Up to 12 — a unit here is not an id already in the database: it is a live read plus a real download inside this request, with the user waiting. Repeated ids are deduplicated. They are ALL checked against the catalogue before a single picture is downloaded (2112 naming the missing one, or the one that is out of stock), and each picture is copied into an upload of the organization: a catalogue's picture URL expires or changes, and a plan published weeks later would carry a broken file. Those uploads count against the storage quota.

        • Optionaltext?: string

          from_text. The article pasted by hand. It wins over url when both come: pasting is what a user does when the download did not work (a paywall, a page that needs JavaScript), so re-downloading to ignore what they wrote would take away their only way out. Truncated to 12.000 characters — the cap is what keeps the estimate honest, since the real charge is per use. Under 200 characters it is not an article, it is the theme, which is prompt and another field (2116).

        • Optionalurl?: string

          Format: uri

          from_text. The article the plan is written from. It is downloaded at creation, and only http/https addresses that resolve to a public IP are accepted — checked again before every redirect (2114). A page that answers something that is not text or HTML, or that carries no usable text once stripped, is a 2113: paste the text in text instead.

      • Optionaltemplate?: "standard" | "from_images" | "from_text" | "from_catalog" | "campaign"

        What the plan is generated FROM. Optional; defaults to standard, which is exactly what every plan did before templates existed — send nothing and nothing changes.

        A template is the **source** of the content, not a different flow: `shared`, `publish_days`, `language`, `tone` and the images stay cross-cutting options, and each template declares which of them it accepts. Sending one it does not accept is a 2106, not a silent ignore.
        
        Read the list, the costs and the fields from `GET /planner_templates`; do not hardcode them.
        
    • options: RequestOptions = {}

    Returns Promise<
        {
            ai_plan: {
                _id: string;
                accounts: string[];
                archived_date?: string;
                attempts: number;
                creation_date: string;
                credits_spent: number;
                destinations?: {
                    destination: {
                        id?: string;
                        name?: string;
                        section_id?: string;
                        section_name?: string;
                    };
                    id_account: string;
                }[];
                error?: {
                    code: number;
                    data?: { [key: string]: unknown };
                    message: string;
                };
                generation_end_date?: string;
                id_client: string;
                id_organization: string;
                keycloak_identifier?: string;
                options: {
                    allow_images: boolean;
                    gallery_uploads: string[];
                    language: string;
                    link?: string;
                    max_images?: number;
                    publish_days: number[];
                    shared: boolean;
                    timezone: string;
                    tone?: string;
                    use_organization_context: boolean;
                    week_start: string;
                };
                orchestrator_result?: Record<string, never>;
                organization_context?: {
                    audience?: string;
                    avoid?: string;
                    blog_url?: string;
                    brand_name?: string;
                    default_tone?: string;
                    description?: string;
                    keywords?: string[];
                    notes?: string;
                    products?: string;
                    sector?: string;
                    shop_url?: string;
                    social_urls?: string[];
                    value_proposition?: string;
                    website?: string;
                };
                prompt: string;
                publications: (
                    | string
                    | {
                        _id: string;
                        ai_generated?: { image: boolean; text: boolean };
                        creation_date: string;
                        destination?: {
                            id?: string;
                            name?: string;
                            section_id?: string;
                            section_name?: string;
                        };
                        engagement_base?: "reach"
                        | "impressions"
                        | "followers";
                        external_identifier?: string;
                        extra_data?: { [key: string]: unknown };
                        files: {
                            _id: string;
                            ai_generated?: {
                                generated_at: string;
                                id_ai_plan?: (...) | (...);
                                model: string;
                                provider: string;
                            };
                            cover_image?: { _id: string; ai_generated?: { generated_at: string; id_ai_plan?: string; model: string; provider: string; }; cover_image?: ...; cover_offset?: number; creation_date: string; file_externals: { external_identifier: string; external_url: string; social_network: "facebook" | ... 12 more ... | "pinterest"; }[]; ... 6 m...;
                            cover_offset?: number;
                            creation_date: string;
                            file_externals: {
                                external_identifier: string;
                                external_url: string;
                                social_network: | (...)
                                | (...)
                                | (...)
                                | (...)
                                | (...)
                                | (...)
                                | (...)
                                | (...)
                                | (...)
                                | (...)
                                | (...)
                                | (...)
                                | (...)
                                | (...);
                            }[];
                            file_format: "mp4"
                            | "jpeg"
                            | "gif"
                            | "png"
                            | "jpg";
                            file_properties: {
                                allowed_social_networks: string[];
                                aspect_ratio: { text: string; value: number };
                                duration: number;
                                height: number;
                                size_in_bytes: number;
                                width: number;
                            };
                            file_type: "video"
                            | "image";
                            id_organization: string;
                            is_temporal: boolean;
                            name: string;
                            public_path: string;
                        }[];
                        id_account: | string
                        | {
                            _id: string;
                            creation_date: string;
                            error_code: number;
                            extra_data?: { is_personal_profile?: ... } & { [key: ...]: ... };
                            followers_count?: number;
                            id_client: string;
                            id_organization: string;
                            image?: string;
                            name: string;
                            next_comments_update?: string;
                            next_stats_update?: string;
                            private_message_link?: string;
                            social_network:
                                | "facebook"
                                | "instagram"
                                | "linkedin"
                                | "tiktok"
                                | "twitter"
                                | "whatsapp"
                                | "youtube"
                                | "google_business"
                                | "bluesky"
                                | "discord"
                                | "telegram"
                                | "threads"
                                | "slack"
                                | "pinterest";
                            username?: string;
                        };
                        id_integration?: string;
                        id_organization: string;
                        link?: string;
                        made_for_kids?: boolean;
                        metrics?: {
                            clicks?: number;
                            comments?: number;
                            engagement?: number;
                            followers?: number;
                            followers_gained?: number;
                            impressions?: number;
                            likes?: number;
                            profile_views?: number;
                            reach?: number;
                            saves?: number;
                            shares?: number;
                            video_views?: number;
                        };
                        name?: string;
                        next_stats_update?: string;
                        pending_publish?: {
                            data?: { [key: string]: unknown };
                            deadline?: string;
                            next_check?: string;
                            temp_keys?: string[];
                        };
                        publication_errors: {
                            code: number;
                            data?: { [key: string]: unknown };
                            message: string;
                        }[];
                        publication_type: | "profile"
                        | "page"
                        | "group"
                        | "reels"
                        | "stories"
                        | "message";
                        publication_warnings?: {
                            code: number;
                            data?: { [key: ...]: ... };
                            message: string;
                        }[];
                        publish_date?: string;
                        reply_control?: | "everyone"
                        | "accounts_you_follow"
                        | "mentioned_only"
                        | "followers_only";
                        retries: number;
                        social_network: | "facebook"
                        | "instagram"
                        | "linkedin"
                        | "tiktok"
                        | "twitter"
                        | "whatsapp"
                        | "youtube"
                        | "google_business"
                        | "bluesky"
                        | "discord"
                        | "telegram"
                        | "threads"
                        | "slack"
                        | "pinterest";
                        state: "ready"
                        | "withErrors"
                        | "sended"
                        | "draft"
                        | "publishing";
                        statistics?: {
                            angers?: number;
                            bookmarks?: number;
                            clicks?: number;
                            comments?: number;
                            engagement?: number;
                            follows?: number;
                            hahas?: number;
                            impressions?: number;
                            likes?: number;
                            loves?: number;
                            negative_feedback?: number;
                            outbound_clicks?: number;
                            page_likes?: number;
                            pin_clicks?: number;
                            playback_0_count?: number;
                            playback_100_count?: number;
                            playback_25_count?: number;
                            playback_50_count?: number;
                            playback_75_count?: number;
                            profile_activity?: number;
                            profile_visits?: number;
                            quotes?: number;
                            reach?: number;
                            reactions?: number;
                            reactions_by_emoji?: { [key: string]: number };
                            replys?: number;
                            retwets?: number;
                            saved?: number;
                            saves?: number;
                            share?: number;
                            shareMentions?: number;
                            shares?: number;
                            sorrys?: number;
                            url_link_clicks?: number;
                            user_profile_clicks?: number;
                            video_views?: number;
                            views?: number;
                            wows?: number;
                        };
                        stats_updated_date?: string;
                        text?: string;
                        title?: string;
                        url?: string;
                        visibility?: "public"
                        | "unlisted"
                        | "private";
                    }
                )[];
                source?: {
                    event?: { date?: string; name?: string };
                    id_account_catalog?: string;
                    id_integration_catalog?: string;
                    images?: { description?: string; id_upload?: string }[];
                    products?: {
                        description?: string;
                        external_id?: string;
                        id_upload?: string;
                        name?: string;
                        permalink?: string;
                        price?: string;
                    }[];
                    text?: string;
                    url?: string;
                };
                state: | "pending"
                | "generating"
                | "generated"
                | "validated"
                | "failed"
                | "cancelled";
                template?: | "standard"
                | "from_images"
                | "from_text"
                | "from_catalog"
                | "campaign";
                warnings?: {
                    code: number;
                    data?: { [key: string]: unknown };
                    message: string;
                }[];
            };
            estimate: {
                available_credits: number;
                base_cost: number;
                estimated_cost: number;
                images_target: number;
                texts_target: number;
            };
            estimated_cost: number;
        },
    >

  • Un plan, con sus publicaciones ya resueltas y con los ficheros de cada una.

    Léelo cuando a tu app le llegue ai_plan_generated o ai_plan_failed. Sin webhook, es el endpoint que se sondea mientras state sea pending o generating. El webhook no se reintenta: si tu endpoint estaba caído cuando el plan terminó, esto sigue diciendo cómo acabó.

    Parameters

    • idClient: string
    • idOrganization: string
    • idAiPlan: string
    • options: RequestOptions = {}

    Returns Promise<
        {
            _id: string;
            accounts: string[];
            archived_date?: string;
            attempts: number;
            creation_date: string;
            credits_spent: number;
            destinations?: {
                destination: {
                    id?: string;
                    name?: string;
                    section_id?: string;
                    section_name?: string;
                };
                id_account: string;
            }[];
            error?: {
                code: number;
                data?: { [key: string]: unknown };
                message: string;
            };
            generation_end_date?: string;
            id_client: string;
            id_organization: string;
            keycloak_identifier?: string;
            options: {
                allow_images: boolean;
                gallery_uploads: string[];
                language: string;
                link?: string;
                max_images?: number;
                publish_days: number[];
                shared: boolean;
                timezone: string;
                tone?: string;
                use_organization_context: boolean;
                week_start: string;
            };
            orchestrator_result?: Record<string, never>;
            organization_context?: {
                audience?: string;
                avoid?: string;
                blog_url?: string;
                brand_name?: string;
                default_tone?: string;
                description?: string;
                keywords?: string[];
                notes?: string;
                products?: string;
                sector?: string;
                shop_url?: string;
                social_urls?: string[];
                value_proposition?: string;
                website?: string;
            };
            prompt: string;
            publications: (
                | string
                | {
                    _id: string;
                    ai_generated?: { image: boolean; text: boolean };
                    creation_date: string;
                    destination?: {
                        id?: string;
                        name?: string;
                        section_id?: string;
                        section_name?: string;
                    };
                    engagement_base?: "reach"
                    | "impressions"
                    | "followers";
                    external_identifier?: string;
                    extra_data?: { [key: string]: unknown };
                    files: {
                        _id: string;
                        ai_generated?: {
                            generated_at: string;
                            id_ai_plan?: string;
                            model: string;
                            provider: string;
                        };
                        cover_image?: { _id: string; ai_generated?: { generated_at: string; id_ai_plan?: string; model: string; provider: string; }; cover_image?: ...; cover_offset?: number; creation_date: string; file_externals: { external_identifier: string; external_url: string; social_network: "facebook" | ... 12 more ... | "pinterest"; }[]; ... 6 m...;
                        cover_offset?: number;
                        creation_date: string;
                        file_externals: {
                            external_identifier: string;
                            external_url: string;
                            social_network: | "facebook"
                            | "instagram"
                            | "linkedin"
                            | "tiktok"
                            | "twitter"
                            | "whatsapp"
                            | "youtube"
                            | "google_business"
                            | "bluesky"
                            | "discord"
                            | "telegram"
                            | "threads"
                            | "slack"
                            | "pinterest";
                        }[];
                        file_format: "mp4"
                        | "jpeg"
                        | "gif"
                        | "png"
                        | "jpg";
                        file_properties: {
                            allowed_social_networks: string[];
                            aspect_ratio: { text: string; value: number };
                            duration: number;
                            height: number;
                            size_in_bytes: number;
                            width: number;
                        };
                        file_type: "video"
                        | "image";
                        id_organization: string;
                        is_temporal: boolean;
                        name: string;
                        public_path: string;
                    }[];
                    id_account: | string
                    | {
                        _id: string;
                        creation_date: string;
                        error_code: number;
                        extra_data?: { is_personal_profile?: (...)
                        | (...)
                        | (...) } & { [key: string]: unknown };
                        followers_count?: number;
                        id_client: string;
                        id_organization: string;
                        image?: string;
                        name: string;
                        next_comments_update?: string;
                        next_stats_update?: string;
                        private_message_link?: string;
                        social_network:
                            | "facebook"
                            | "instagram"
                            | "linkedin"
                            | "tiktok"
                            | "twitter"
                            | "whatsapp"
                            | "youtube"
                            | "google_business"
                            | "bluesky"
                            | "discord"
                            | "telegram"
                            | "threads"
                            | "slack"
                            | "pinterest";
                        username?: string;
                    };
                    id_integration?: string;
                    id_organization: string;
                    link?: string;
                    made_for_kids?: boolean;
                    metrics?: {
                        clicks?: number;
                        comments?: number;
                        engagement?: number;
                        followers?: number;
                        followers_gained?: number;
                        impressions?: number;
                        likes?: number;
                        profile_views?: number;
                        reach?: number;
                        saves?: number;
                        shares?: number;
                        video_views?: number;
                    };
                    name?: string;
                    next_stats_update?: string;
                    pending_publish?: {
                        data?: { [key: string]: unknown };
                        deadline?: string;
                        next_check?: string;
                        temp_keys?: string[];
                    };
                    publication_errors: {
                        code: number;
                        data?: { [key: string]: unknown };
                        message: string;
                    }[];
                    publication_type: | "profile"
                    | "page"
                    | "group"
                    | "reels"
                    | "stories"
                    | "message";
                    publication_warnings?: {
                        code: number;
                        data?: { [key: string]: unknown };
                        message: string;
                    }[];
                    publish_date?: string;
                    reply_control?: | "everyone"
                    | "accounts_you_follow"
                    | "mentioned_only"
                    | "followers_only";
                    retries: number;
                    social_network: | "facebook"
                    | "instagram"
                    | "linkedin"
                    | "tiktok"
                    | "twitter"
                    | "whatsapp"
                    | "youtube"
                    | "google_business"
                    | "bluesky"
                    | "discord"
                    | "telegram"
                    | "threads"
                    | "slack"
                    | "pinterest";
                    state: "ready"
                    | "withErrors"
                    | "sended"
                    | "draft"
                    | "publishing";
                    statistics?: {
                        angers?: number;
                        bookmarks?: number;
                        clicks?: number;
                        comments?: number;
                        engagement?: number;
                        follows?: number;
                        hahas?: number;
                        impressions?: number;
                        likes?: number;
                        loves?: number;
                        negative_feedback?: number;
                        outbound_clicks?: number;
                        page_likes?: number;
                        pin_clicks?: number;
                        playback_0_count?: number;
                        playback_100_count?: number;
                        playback_25_count?: number;
                        playback_50_count?: number;
                        playback_75_count?: number;
                        profile_activity?: number;
                        profile_visits?: number;
                        quotes?: number;
                        reach?: number;
                        reactions?: number;
                        reactions_by_emoji?: { [key: string]: number };
                        replys?: number;
                        retwets?: number;
                        saved?: number;
                        saves?: number;
                        share?: number;
                        shareMentions?: number;
                        shares?: number;
                        sorrys?: number;
                        url_link_clicks?: number;
                        user_profile_clicks?: number;
                        video_views?: number;
                        views?: number;
                        wows?: number;
                    };
                    stats_updated_date?: string;
                    text?: string;
                    title?: string;
                    url?: string;
                    visibility?: "public"
                    | "unlisted"
                    | "private";
                }
            )[];
            source?: {
                event?: { date?: string; name?: string };
                id_account_catalog?: string;
                id_integration_catalog?: string;
                images?: { description?: string; id_upload?: string }[];
                products?: {
                    description?: string;
                    external_id?: string;
                    id_upload?: string;
                    name?: string;
                    permalink?: string;
                    price?: string;
                }[];
                text?: string;
                url?: string;
            };
            state: | "pending"
            | "generating"
            | "generated"
            | "validated"
            | "failed"
            | "cancelled";
            template?: | "standard"
            | "from_images"
            | "from_text"
            | "from_catalog"
            | "campaign";
            warnings?: {
                code: number;
                data?: { [key: string]: unknown };
                message: string;
            }[];
        },
    >

  • Los planes de la organización, encadenando páginas.

    Parameters

    Returns AsyncGenerator<
        {
            _id: string;
            accounts: string[];
            archived_date?: string;
            attempts: number;
            creation_date: string;
            credits_spent: number;
            destinations?: {
                destination: {
                    id?: string;
                    name?: string;
                    section_id?: string;
                    section_name?: string;
                };
                id_account: string;
            }[];
            error?: {
                code: number;
                data?: { [key: string]: unknown };
                message: string;
            };
            generation_end_date?: string;
            id_client: string;
            id_organization: string;
            keycloak_identifier?: string;
            options: {
                allow_images: boolean;
                gallery_uploads: string[];
                language: string;
                link?: string;
                max_images?: number;
                publish_days: number[];
                shared: boolean;
                timezone: string;
                tone?: string;
                use_organization_context: boolean;
                week_start: string;
            };
            orchestrator_result?: Record<string, never>;
            organization_context?: {
                audience?: string;
                avoid?: string;
                blog_url?: string;
                brand_name?: string;
                default_tone?: string;
                description?: string;
                keywords?: string[];
                notes?: string;
                products?: string;
                sector?: string;
                shop_url?: string;
                social_urls?: string[];
                value_proposition?: string;
                website?: string;
            };
            prompt: string;
            publications: (
                | string
                | {
                    _id: string;
                    ai_generated?: { image: boolean; text: boolean };
                    creation_date: string;
                    destination?: {
                        id?: string;
                        name?: string;
                        section_id?: string;
                        section_name?: string;
                    };
                    engagement_base?: "reach"
                    | "impressions"
                    | "followers";
                    external_identifier?: string;
                    extra_data?: { [key: string]: unknown };
                    files: {
                        _id: string;
                        ai_generated?: {
                            generated_at: string;
                            id_ai_plan?: string;
                            model: string;
                            provider: string;
                        };
                        cover_image?: { _id: string; ai_generated?: { generated_at: string; id_ai_plan?: string; model: string; provider: string; }; cover_image?: ...; cover_offset?: number; creation_date: string; file_externals: { external_identifier: string; external_url: string; social_network: "facebook" | ... 12 more ... | "pinterest"; }[]; ... 6 m...;
                        cover_offset?: number;
                        creation_date: string;
                        file_externals: {
                            external_identifier: string;
                            external_url: string;
                            social_network: | "facebook"
                            | "instagram"
                            | "linkedin"
                            | "tiktok"
                            | "twitter"
                            | "whatsapp"
                            | "youtube"
                            | "google_business"
                            | "bluesky"
                            | "discord"
                            | "telegram"
                            | "threads"
                            | "slack"
                            | "pinterest";
                        }[];
                        file_format: "mp4"
                        | "jpeg"
                        | "gif"
                        | "png"
                        | "jpg";
                        file_properties: {
                            allowed_social_networks: string[];
                            aspect_ratio: { text: string; value: number };
                            duration: number;
                            height: number;
                            size_in_bytes: number;
                            width: number;
                        };
                        file_type: "video"
                        | "image";
                        id_organization: string;
                        is_temporal: boolean;
                        name: string;
                        public_path: string;
                    }[];
                    id_account: | string
                    | {
                        _id: string;
                        creation_date: string;
                        error_code: number;
                        extra_data?: { is_personal_profile?: (...)
                        | (...)
                        | (...) } & { [key: string]: unknown };
                        followers_count?: number;
                        id_client: string;
                        id_organization: string;
                        image?: string;
                        name: string;
                        next_comments_update?: string;
                        next_stats_update?: string;
                        private_message_link?: string;
                        social_network:
                            | "facebook"
                            | "instagram"
                            | "linkedin"
                            | "tiktok"
                            | "twitter"
                            | "whatsapp"
                            | "youtube"
                            | "google_business"
                            | "bluesky"
                            | "discord"
                            | "telegram"
                            | "threads"
                            | "slack"
                            | "pinterest";
                        username?: string;
                    };
                    id_integration?: string;
                    id_organization: string;
                    link?: string;
                    made_for_kids?: boolean;
                    metrics?: {
                        clicks?: number;
                        comments?: number;
                        engagement?: number;
                        followers?: number;
                        followers_gained?: number;
                        impressions?: number;
                        likes?: number;
                        profile_views?: number;
                        reach?: number;
                        saves?: number;
                        shares?: number;
                        video_views?: number;
                    };
                    name?: string;
                    next_stats_update?: string;
                    pending_publish?: {
                        data?: { [key: string]: unknown };
                        deadline?: string;
                        next_check?: string;
                        temp_keys?: string[];
                    };
                    publication_errors: {
                        code: number;
                        data?: { [key: string]: unknown };
                        message: string;
                    }[];
                    publication_type: | "profile"
                    | "page"
                    | "group"
                    | "reels"
                    | "stories"
                    | "message";
                    publication_warnings?: {
                        code: number;
                        data?: { [key: string]: unknown };
                        message: string;
                    }[];
                    publish_date?: string;
                    reply_control?: | "everyone"
                    | "accounts_you_follow"
                    | "mentioned_only"
                    | "followers_only";
                    retries: number;
                    social_network: | "facebook"
                    | "instagram"
                    | "linkedin"
                    | "tiktok"
                    | "twitter"
                    | "whatsapp"
                    | "youtube"
                    | "google_business"
                    | "bluesky"
                    | "discord"
                    | "telegram"
                    | "threads"
                    | "slack"
                    | "pinterest";
                    state: "ready"
                    | "withErrors"
                    | "sended"
                    | "draft"
                    | "publishing";
                    statistics?: {
                        angers?: number;
                        bookmarks?: number;
                        clicks?: number;
                        comments?: number;
                        engagement?: number;
                        follows?: number;
                        hahas?: number;
                        impressions?: number;
                        likes?: number;
                        loves?: number;
                        negative_feedback?: number;
                        outbound_clicks?: number;
                        page_likes?: number;
                        pin_clicks?: number;
                        playback_0_count?: number;
                        playback_100_count?: number;
                        playback_25_count?: number;
                        playback_50_count?: number;
                        playback_75_count?: number;
                        profile_activity?: number;
                        profile_visits?: number;
                        quotes?: number;
                        reach?: number;
                        reactions?: number;
                        reactions_by_emoji?: { [key: string]: number };
                        replys?: number;
                        retwets?: number;
                        saved?: number;
                        saves?: number;
                        share?: number;
                        shareMentions?: number;
                        shares?: number;
                        sorrys?: number;
                        url_link_clicks?: number;
                        user_profile_clicks?: number;
                        video_views?: number;
                        views?: number;
                        wows?: number;
                    };
                    stats_updated_date?: string;
                    text?: string;
                    title?: string;
                    url?: string;
                    visibility?: "public"
                    | "unlisted"
                    | "private";
                }
            )[];
            source?: {
                event?: { date?: string; name?: string };
                id_account_catalog?: string;
                id_integration_catalog?: string;
                images?: { description?: string; id_upload?: string }[];
                products?: {
                    description?: string;
                    external_id?: string;
                    id_upload?: string;
                    name?: string;
                    permalink?: string;
                    price?: string;
                }[];
                text?: string;
                url?: string;
            };
            state: | "pending"
            | "generating"
            | "generated"
            | "validated"
            | "failed"
            | "cancelled";
            template?: | "standard"
            | "from_images"
            | "from_text"
            | "from_catalog"
            | "campaign";
            warnings?: {
                code: number;
                data?: { [key: string]: unknown };
                message: string;
            }[];
        },
    >

  • Los planes ACTIVOS de la organización, del más reciente al más antiguo.

    Los cancelados no salen —ni los archivados, que se piden con archived: true— y aquí publications son identificadores, no las publicaciones enteras: para eso está get. Sin limit vuelven todos.

    const activos = await pv.aiPlans.list(clientId, orgId);
    const guardados = await pv.aiPlans.list(clientId, orgId, { archived: true });

    Parameters

    Returns Promise<
        Paginated<
            {
                _id: string;
                accounts: string[];
                archived_date?: string;
                attempts: number;
                creation_date: string;
                credits_spent: number;
                destinations?: {
                    destination: {
                        id?: string;
                        name?: string;
                        section_id?: string;
                        section_name?: string;
                    };
                    id_account: string;
                }[];
                error?: {
                    code: number;
                    data?: { [key: string]: unknown };
                    message: string;
                };
                generation_end_date?: string;
                id_client: string;
                id_organization: string;
                keycloak_identifier?: string;
                options: {
                    allow_images: boolean;
                    gallery_uploads: string[];
                    language: string;
                    link?: string;
                    max_images?: number;
                    publish_days: number[];
                    shared: boolean;
                    timezone: string;
                    tone?: string;
                    use_organization_context: boolean;
                    week_start: string;
                };
                orchestrator_result?: Record<string, never>;
                organization_context?: {
                    audience?: string;
                    avoid?: string;
                    blog_url?: string;
                    brand_name?: string;
                    default_tone?: string;
                    description?: string;
                    keywords?: string[];
                    notes?: string;
                    products?: string;
                    sector?: string;
                    shop_url?: string;
                    social_urls?: string[];
                    value_proposition?: string;
                    website?: string;
                };
                prompt: string;
                publications: (
                    | string
                    | {
                        _id: string;
                        ai_generated?: { image: boolean; text: boolean };
                        creation_date: string;
                        destination?: {
                            id?: string;
                            name?: string;
                            section_id?: string;
                            section_name?: string;
                        };
                        engagement_base?: "reach"
                        | "impressions"
                        | "followers";
                        external_identifier?: string;
                        extra_data?: { [key: string]: unknown };
                        files: {
                            _id: string;
                            ai_generated?: {
                                generated_at: string;
                                id_ai_plan?: (...) | (...);
                                model: string;
                                provider: string;
                            };
                            cover_image?: { _id: string; ai_generated?: { generated_at: string; id_ai_plan?: string; model: string; provider: string; }; cover_image?: ...; cover_offset?: number; creation_date: string; file_externals: { external_identifier: string; external_url: string; social_network: "facebook" | ... 12 more ... | "pinterest"; }[]; ... 6 m...;
                            cover_offset?: number;
                            creation_date: string;
                            file_externals: {
                                external_identifier: string;
                                external_url: string;
                                social_network: | (...)
                                | (...)
                                | (...)
                                | (...)
                                | (...)
                                | (...)
                                | (...)
                                | (...)
                                | (...)
                                | (...)
                                | (...)
                                | (...)
                                | (...)
                                | (...);
                            }[];
                            file_format: "mp4"
                            | "jpeg"
                            | "gif"
                            | "png"
                            | "jpg";
                            file_properties: {
                                allowed_social_networks: string[];
                                aspect_ratio: { text: string; value: number };
                                duration: number;
                                height: number;
                                size_in_bytes: number;
                                width: number;
                            };
                            file_type: "video"
                            | "image";
                            id_organization: string;
                            is_temporal: boolean;
                            name: string;
                            public_path: string;
                        }[];
                        id_account: | string
                        | {
                            _id: string;
                            creation_date: string;
                            error_code: number;
                            extra_data?: { is_personal_profile?: ... } & { [key: ...]: ... };
                            followers_count?: number;
                            id_client: string;
                            id_organization: string;
                            image?: string;
                            name: string;
                            next_comments_update?: string;
                            next_stats_update?: string;
                            private_message_link?: string;
                            social_network:
                                | "facebook"
                                | "instagram"
                                | "linkedin"
                                | "tiktok"
                                | "twitter"
                                | "whatsapp"
                                | "youtube"
                                | "google_business"
                                | "bluesky"
                                | "discord"
                                | "telegram"
                                | "threads"
                                | "slack"
                                | "pinterest";
                            username?: string;
                        };
                        id_integration?: string;
                        id_organization: string;
                        link?: string;
                        made_for_kids?: boolean;
                        metrics?: {
                            clicks?: number;
                            comments?: number;
                            engagement?: number;
                            followers?: number;
                            followers_gained?: number;
                            impressions?: number;
                            likes?: number;
                            profile_views?: number;
                            reach?: number;
                            saves?: number;
                            shares?: number;
                            video_views?: number;
                        };
                        name?: string;
                        next_stats_update?: string;
                        pending_publish?: {
                            data?: { [key: string]: unknown };
                            deadline?: string;
                            next_check?: string;
                            temp_keys?: string[];
                        };
                        publication_errors: {
                            code: number;
                            data?: { [key: string]: unknown };
                            message: string;
                        }[];
                        publication_type: | "profile"
                        | "page"
                        | "group"
                        | "reels"
                        | "stories"
                        | "message";
                        publication_warnings?: {
                            code: number;
                            data?: { [key: ...]: ... };
                            message: string;
                        }[];
                        publish_date?: string;
                        reply_control?: | "everyone"
                        | "accounts_you_follow"
                        | "mentioned_only"
                        | "followers_only";
                        retries: number;
                        social_network: | "facebook"
                        | "instagram"
                        | "linkedin"
                        | "tiktok"
                        | "twitter"
                        | "whatsapp"
                        | "youtube"
                        | "google_business"
                        | "bluesky"
                        | "discord"
                        | "telegram"
                        | "threads"
                        | "slack"
                        | "pinterest";
                        state: "ready"
                        | "withErrors"
                        | "sended"
                        | "draft"
                        | "publishing";
                        statistics?: {
                            angers?: number;
                            bookmarks?: number;
                            clicks?: number;
                            comments?: number;
                            engagement?: number;
                            follows?: number;
                            hahas?: number;
                            impressions?: number;
                            likes?: number;
                            loves?: number;
                            negative_feedback?: number;
                            outbound_clicks?: number;
                            page_likes?: number;
                            pin_clicks?: number;
                            playback_0_count?: number;
                            playback_100_count?: number;
                            playback_25_count?: number;
                            playback_50_count?: number;
                            playback_75_count?: number;
                            profile_activity?: number;
                            profile_visits?: number;
                            quotes?: number;
                            reach?: number;
                            reactions?: number;
                            reactions_by_emoji?: { [key: string]: number };
                            replys?: number;
                            retwets?: number;
                            saved?: number;
                            saves?: number;
                            share?: number;
                            shareMentions?: number;
                            shares?: number;
                            sorrys?: number;
                            url_link_clicks?: number;
                            user_profile_clicks?: number;
                            video_views?: number;
                            views?: number;
                            wows?: number;
                        };
                        stats_updated_date?: string;
                        text?: string;
                        title?: string;
                        url?: string;
                        visibility?: "public"
                        | "unlisted"
                        | "private";
                    }
                )[];
                source?: {
                    event?: { date?: string; name?: string };
                    id_account_catalog?: string;
                    id_integration_catalog?: string;
                    images?: { description?: string; id_upload?: string }[];
                    products?: {
                        description?: string;
                        external_id?: string;
                        id_upload?: string;
                        name?: string;
                        permalink?: string;
                        price?: string;
                    }[];
                    text?: string;
                    url?: string;
                };
                state: | "pending"
                | "generating"
                | "generated"
                | "validated"
                | "failed"
                | "cancelled";
                template?: | "standard"
                | "from_images"
                | "from_text"
                | "from_catalog"
                | "campaign";
                warnings?: {
                    code: number;
                    data?: { [key: string]: unknown };
                    message: string;
                }[];
            },
        >,
    >

  • Regenera con IA el texto o la imagen de UNA publicación del plan. Cuesta créditos cada vez.

    credits_spent de la respuesta es el total del plan, no lo que costó esta llamada.

    "image" depende de la plantilla del plan, no sólo de que el plan permitiera imágenes: la que no generó la imagen tampoco la regenera. Míralo en regenerate.image de CatalogResource.plannerTemplates antes de ofrecer el botón — en from_images y en from_catalog sería cobrarle 70 créditos al usuario por sustituir su propia foto por una inventada.

    Parameters

    Returns Promise<AiPlanRegenerateResult>

  • Borra el plan y sus publicaciones que aún no han salido: las drafts generadas y, si ya se había validado, las que quedaran programadas. Las ya publicadas se quedan —borrarlas aquí no las quitaría de la red, sólo perdería su historial— y la que se está publicando en ese instante tampoco se toca.

    El plan en sí no se borra del todo: pasa a cancelled, desaparece de list y get lo sigue devolviendo. Los créditos gastados no se devuelven y un plan generating no se puede borrar (2102): hay que esperar a que el job termine.

    Si lo que se quiere es dejar de verlo sin perder nada, archive.

    Parameters

    • idClient: string
    • idOrganization: string
    • idAiPlan: string
    • options: RequestOptions = {}

    Returns Promise<void>

  • Qué rindió cada plan con lo que publicó, el agregado por plantilla y el total: la respuesta a «¿qué plan funcionó mejor?». Pide ai_plans:read y publication_stats:read.

    Lo que sorprende:

    • El rango filtra por la SEMANA del plan (week_start), no por cuándo se creó: un plan creado hoy para la semana que viene todavía no ha publicado nada.
    • Sólo salen los planes que han publicado algo. Los archivados sí —archivar es sólo visibilidad—; los cancelados no.
    • El orden por defecto es interacciones por publicación medida, no el total: el total premia al plan de siete cuentas aunque cada post rinda la mitad. Y sólo compiten los planes con ranked: true; los demás van detrás.
    • Cubre ESTA organización, no sus hijas, al revés que el bloque ai_plan_results de DashboardResource.summary.

    No envuelve la respuesta en un Paginated: además de la página trae totals y by_template, que no dependen de ella.

    const { by_template, ai_plans } = await pv.aiPlans.results(clientId, orgId, {
    from_date: "2026-06-01T00:00:00Z",
    social_network: ["instagram"],
    });
    const mejor = ai_plans.find((plan) => plan.ranked);

    Parameters

    Returns Promise<
        {
            ai_plans: {
                accounts: number;
                archived_date?: string;
                creation_date: string;
                credits_per_engagement?: number;
                credits_spent: number;
                engagement_per_publication?: number;
                engagement_vs_average?: number;
                expected_engagement_per_publication?: number;
                id_ai_plan: string;
                id_organization: string;
                last_publish_date?: string;
                maturing: boolean;
                metrics: {
                    clicks?: number;
                    comments?: number;
                    engagement?: number;
                    followers?: number;
                    followers_gained?: number;
                    impressions?: number;
                    likes?: number;
                    profile_views?: number;
                    reach?: number;
                    saves?: number;
                    shares?: number;
                    video_views?: number;
                };
                prompt: string;
                publications: {
                    failed: number;
                    measured: number;
                    published: number;
                    scheduled: number;
                    total: number;
                };
                ranked: boolean;
                social_networks: (
                    | "facebook"
                    | "instagram"
                    | "linkedin"
                    | "tiktok"
                    | "twitter"
                    | "whatsapp"
                    | "youtube"
                    | "google_business"
                    | "bluesky"
                    | "discord"
                    | "telegram"
                    | "threads"
                    | "slack"
                    | "pinterest"
                )[];
                state: "generated"
                | "validated";
                template:
                    | "standard"
                    | "from_images"
                    | "from_text"
                    | "from_catalog"
                    | "campaign";
                week_start: string;
            }[];
            by_template: (
                {
                    credits_per_engagement?: number;
                    credits_spent: number;
                    engagement_per_publication?: number;
                    engagement_vs_average?: number;
                    expected_engagement_per_publication?: number;
                    metrics: {
                        clicks?: number;
                        comments?: number;
                        engagement?: number;
                        followers?: number;
                        followers_gained?: number;
                        impressions?: number;
                        likes?: number;
                        profile_views?: number;
                        reach?: number;
                        saves?: number;
                        shares?: number;
                        video_views?: number;
                    };
                    plans: number;
                    publications: { measured: number; published: number };
                    ranked_plans: number;
                } & {
                    template: | "standard"
                    | "from_images"
                    | "from_text"
                    | "from_catalog"
                    | "campaign";
                }
            )[];
            range: {
                from_date: string;
                previous_from_date?: string;
                previous_to_date?: string;
                to_date: string;
            };
            sort: string;
            total: number;
            totals: {
                credits_per_engagement?: number;
                credits_spent: number;
                engagement_per_publication?: number;
                engagement_vs_average?: number;
                expected_engagement_per_publication?: number;
                metrics: {
                    clicks?: number;
                    comments?: number;
                    engagement?: number;
                    followers?: number;
                    followers_gained?: number;
                    impressions?: number;
                    likes?: number;
                    profile_views?: number;
                    reach?: number;
                    saves?: number;
                    shares?: number;
                    video_views?: number;
                };
                plans: number;
                publications: { measured: number; published: number };
                ranked_plans: number;
            };
        },
    >

  • Vuelve a encolar un plan failed con los mismos datos. El estado regresa a pending y el final vuelve a llegar como tras create(): por webhook, o sondeando.

    Usa el contexto de marca copiado al crear el plan, no el actual: el plan es reproducible aunque alguien haya editado la configuración entretanto.

    Parameters

    • idClient: string
    • idOrganization: string
    • idAiPlan: string
    • options: RequestOptions = {}

    Returns Promise<
        {
            _id: string;
            accounts: string[];
            archived_date?: string;
            attempts: number;
            creation_date: string;
            credits_spent: number;
            destinations?: {
                destination: {
                    id?: string;
                    name?: string;
                    section_id?: string;
                    section_name?: string;
                };
                id_account: string;
            }[];
            error?: {
                code: number;
                data?: { [key: string]: unknown };
                message: string;
            };
            generation_end_date?: string;
            id_client: string;
            id_organization: string;
            keycloak_identifier?: string;
            options: {
                allow_images: boolean;
                gallery_uploads: string[];
                language: string;
                link?: string;
                max_images?: number;
                publish_days: number[];
                shared: boolean;
                timezone: string;
                tone?: string;
                use_organization_context: boolean;
                week_start: string;
            };
            orchestrator_result?: Record<string, never>;
            organization_context?: {
                audience?: string;
                avoid?: string;
                blog_url?: string;
                brand_name?: string;
                default_tone?: string;
                description?: string;
                keywords?: string[];
                notes?: string;
                products?: string;
                sector?: string;
                shop_url?: string;
                social_urls?: string[];
                value_proposition?: string;
                website?: string;
            };
            prompt: string;
            publications: (
                | string
                | {
                    _id: string;
                    ai_generated?: { image: boolean; text: boolean };
                    creation_date: string;
                    destination?: {
                        id?: string;
                        name?: string;
                        section_id?: string;
                        section_name?: string;
                    };
                    engagement_base?: "reach"
                    | "impressions"
                    | "followers";
                    external_identifier?: string;
                    extra_data?: { [key: string]: unknown };
                    files: {
                        _id: string;
                        ai_generated?: {
                            generated_at: string;
                            id_ai_plan?: string;
                            model: string;
                            provider: string;
                        };
                        cover_image?: { _id: string; ai_generated?: { generated_at: string; id_ai_plan?: string; model: string; provider: string; }; cover_image?: ...; cover_offset?: number; creation_date: string; file_externals: { external_identifier: string; external_url: string; social_network: "facebook" | ... 12 more ... | "pinterest"; }[]; ... 6 m...;
                        cover_offset?: number;
                        creation_date: string;
                        file_externals: {
                            external_identifier: string;
                            external_url: string;
                            social_network: | "facebook"
                            | "instagram"
                            | "linkedin"
                            | "tiktok"
                            | "twitter"
                            | "whatsapp"
                            | "youtube"
                            | "google_business"
                            | "bluesky"
                            | "discord"
                            | "telegram"
                            | "threads"
                            | "slack"
                            | "pinterest";
                        }[];
                        file_format: "mp4"
                        | "jpeg"
                        | "gif"
                        | "png"
                        | "jpg";
                        file_properties: {
                            allowed_social_networks: string[];
                            aspect_ratio: { text: string; value: number };
                            duration: number;
                            height: number;
                            size_in_bytes: number;
                            width: number;
                        };
                        file_type: "video"
                        | "image";
                        id_organization: string;
                        is_temporal: boolean;
                        name: string;
                        public_path: string;
                    }[];
                    id_account: | string
                    | {
                        _id: string;
                        creation_date: string;
                        error_code: number;
                        extra_data?: { is_personal_profile?: (...)
                        | (...)
                        | (...) } & { [key: string]: unknown };
                        followers_count?: number;
                        id_client: string;
                        id_organization: string;
                        image?: string;
                        name: string;
                        next_comments_update?: string;
                        next_stats_update?: string;
                        private_message_link?: string;
                        social_network:
                            | "facebook"
                            | "instagram"
                            | "linkedin"
                            | "tiktok"
                            | "twitter"
                            | "whatsapp"
                            | "youtube"
                            | "google_business"
                            | "bluesky"
                            | "discord"
                            | "telegram"
                            | "threads"
                            | "slack"
                            | "pinterest";
                        username?: string;
                    };
                    id_integration?: string;
                    id_organization: string;
                    link?: string;
                    made_for_kids?: boolean;
                    metrics?: {
                        clicks?: number;
                        comments?: number;
                        engagement?: number;
                        followers?: number;
                        followers_gained?: number;
                        impressions?: number;
                        likes?: number;
                        profile_views?: number;
                        reach?: number;
                        saves?: number;
                        shares?: number;
                        video_views?: number;
                    };
                    name?: string;
                    next_stats_update?: string;
                    pending_publish?: {
                        data?: { [key: string]: unknown };
                        deadline?: string;
                        next_check?: string;
                        temp_keys?: string[];
                    };
                    publication_errors: {
                        code: number;
                        data?: { [key: string]: unknown };
                        message: string;
                    }[];
                    publication_type: | "profile"
                    | "page"
                    | "group"
                    | "reels"
                    | "stories"
                    | "message";
                    publication_warnings?: {
                        code: number;
                        data?: { [key: string]: unknown };
                        message: string;
                    }[];
                    publish_date?: string;
                    reply_control?: | "everyone"
                    | "accounts_you_follow"
                    | "mentioned_only"
                    | "followers_only";
                    retries: number;
                    social_network: | "facebook"
                    | "instagram"
                    | "linkedin"
                    | "tiktok"
                    | "twitter"
                    | "whatsapp"
                    | "youtube"
                    | "google_business"
                    | "bluesky"
                    | "discord"
                    | "telegram"
                    | "threads"
                    | "slack"
                    | "pinterest";
                    state: "ready"
                    | "withErrors"
                    | "sended"
                    | "draft"
                    | "publishing";
                    statistics?: {
                        angers?: number;
                        bookmarks?: number;
                        clicks?: number;
                        comments?: number;
                        engagement?: number;
                        follows?: number;
                        hahas?: number;
                        impressions?: number;
                        likes?: number;
                        loves?: number;
                        negative_feedback?: number;
                        outbound_clicks?: number;
                        page_likes?: number;
                        pin_clicks?: number;
                        playback_0_count?: number;
                        playback_100_count?: number;
                        playback_25_count?: number;
                        playback_50_count?: number;
                        playback_75_count?: number;
                        profile_activity?: number;
                        profile_visits?: number;
                        quotes?: number;
                        reach?: number;
                        reactions?: number;
                        reactions_by_emoji?: { [key: string]: number };
                        replys?: number;
                        retwets?: number;
                        saved?: number;
                        saves?: number;
                        share?: number;
                        shareMentions?: number;
                        shares?: number;
                        sorrys?: number;
                        url_link_clicks?: number;
                        user_profile_clicks?: number;
                        video_views?: number;
                        views?: number;
                        wows?: number;
                    };
                    stats_updated_date?: string;
                    text?: string;
                    title?: string;
                    url?: string;
                    visibility?: "public"
                    | "unlisted"
                    | "private";
                }
            )[];
            source?: {
                event?: { date?: string; name?: string };
                id_account_catalog?: string;
                id_integration_catalog?: string;
                images?: { description?: string; id_upload?: string }[];
                products?: {
                    description?: string;
                    external_id?: string;
                    id_upload?: string;
                    name?: string;
                    permalink?: string;
                    price?: string;
                }[];
                text?: string;
                url?: string;
            };
            state: | "pending"
            | "generating"
            | "generated"
            | "validated"
            | "failed"
            | "cancelled";
            template?: | "standard"
            | "from_images"
            | "from_text"
            | "from_catalog"
            | "campaign";
            warnings?: {
                code: number;
                data?: { [key: string]: unknown };
                message: string;
            }[];
        },
    >

  • Devuelve el plan al listado activo. Sobre un plan que no estaba archivado no hace nada.

    Parameters

    • idClient: string
    • idOrganization: string
    • idAiPlan: string
    • options: RequestOptions = {}

    Returns Promise<
        {
            _id: string;
            accounts: string[];
            archived_date?: string;
            attempts: number;
            creation_date: string;
            credits_spent: number;
            destinations?: {
                destination: {
                    id?: string;
                    name?: string;
                    section_id?: string;
                    section_name?: string;
                };
                id_account: string;
            }[];
            error?: {
                code: number;
                data?: { [key: string]: unknown };
                message: string;
            };
            generation_end_date?: string;
            id_client: string;
            id_organization: string;
            keycloak_identifier?: string;
            options: {
                allow_images: boolean;
                gallery_uploads: string[];
                language: string;
                link?: string;
                max_images?: number;
                publish_days: number[];
                shared: boolean;
                timezone: string;
                tone?: string;
                use_organization_context: boolean;
                week_start: string;
            };
            orchestrator_result?: Record<string, never>;
            organization_context?: {
                audience?: string;
                avoid?: string;
                blog_url?: string;
                brand_name?: string;
                default_tone?: string;
                description?: string;
                keywords?: string[];
                notes?: string;
                products?: string;
                sector?: string;
                shop_url?: string;
                social_urls?: string[];
                value_proposition?: string;
                website?: string;
            };
            prompt: string;
            publications: (
                | string
                | {
                    _id: string;
                    ai_generated?: { image: boolean; text: boolean };
                    creation_date: string;
                    destination?: {
                        id?: string;
                        name?: string;
                        section_id?: string;
                        section_name?: string;
                    };
                    engagement_base?: "reach"
                    | "impressions"
                    | "followers";
                    external_identifier?: string;
                    extra_data?: { [key: string]: unknown };
                    files: {
                        _id: string;
                        ai_generated?: {
                            generated_at: string;
                            id_ai_plan?: string;
                            model: string;
                            provider: string;
                        };
                        cover_image?: { _id: string; ai_generated?: { generated_at: string; id_ai_plan?: string; model: string; provider: string; }; cover_image?: ...; cover_offset?: number; creation_date: string; file_externals: { external_identifier: string; external_url: string; social_network: "facebook" | ... 12 more ... | "pinterest"; }[]; ... 6 m...;
                        cover_offset?: number;
                        creation_date: string;
                        file_externals: {
                            external_identifier: string;
                            external_url: string;
                            social_network: | "facebook"
                            | "instagram"
                            | "linkedin"
                            | "tiktok"
                            | "twitter"
                            | "whatsapp"
                            | "youtube"
                            | "google_business"
                            | "bluesky"
                            | "discord"
                            | "telegram"
                            | "threads"
                            | "slack"
                            | "pinterest";
                        }[];
                        file_format: "mp4"
                        | "jpeg"
                        | "gif"
                        | "png"
                        | "jpg";
                        file_properties: {
                            allowed_social_networks: string[];
                            aspect_ratio: { text: string; value: number };
                            duration: number;
                            height: number;
                            size_in_bytes: number;
                            width: number;
                        };
                        file_type: "video"
                        | "image";
                        id_organization: string;
                        is_temporal: boolean;
                        name: string;
                        public_path: string;
                    }[];
                    id_account: | string
                    | {
                        _id: string;
                        creation_date: string;
                        error_code: number;
                        extra_data?: { is_personal_profile?: (...)
                        | (...)
                        | (...) } & { [key: string]: unknown };
                        followers_count?: number;
                        id_client: string;
                        id_organization: string;
                        image?: string;
                        name: string;
                        next_comments_update?: string;
                        next_stats_update?: string;
                        private_message_link?: string;
                        social_network:
                            | "facebook"
                            | "instagram"
                            | "linkedin"
                            | "tiktok"
                            | "twitter"
                            | "whatsapp"
                            | "youtube"
                            | "google_business"
                            | "bluesky"
                            | "discord"
                            | "telegram"
                            | "threads"
                            | "slack"
                            | "pinterest";
                        username?: string;
                    };
                    id_integration?: string;
                    id_organization: string;
                    link?: string;
                    made_for_kids?: boolean;
                    metrics?: {
                        clicks?: number;
                        comments?: number;
                        engagement?: number;
                        followers?: number;
                        followers_gained?: number;
                        impressions?: number;
                        likes?: number;
                        profile_views?: number;
                        reach?: number;
                        saves?: number;
                        shares?: number;
                        video_views?: number;
                    };
                    name?: string;
                    next_stats_update?: string;
                    pending_publish?: {
                        data?: { [key: string]: unknown };
                        deadline?: string;
                        next_check?: string;
                        temp_keys?: string[];
                    };
                    publication_errors: {
                        code: number;
                        data?: { [key: string]: unknown };
                        message: string;
                    }[];
                    publication_type: | "profile"
                    | "page"
                    | "group"
                    | "reels"
                    | "stories"
                    | "message";
                    publication_warnings?: {
                        code: number;
                        data?: { [key: string]: unknown };
                        message: string;
                    }[];
                    publish_date?: string;
                    reply_control?: | "everyone"
                    | "accounts_you_follow"
                    | "mentioned_only"
                    | "followers_only";
                    retries: number;
                    social_network: | "facebook"
                    | "instagram"
                    | "linkedin"
                    | "tiktok"
                    | "twitter"
                    | "whatsapp"
                    | "youtube"
                    | "google_business"
                    | "bluesky"
                    | "discord"
                    | "telegram"
                    | "threads"
                    | "slack"
                    | "pinterest";
                    state: "ready"
                    | "withErrors"
                    | "sended"
                    | "draft"
                    | "publishing";
                    statistics?: {
                        angers?: number;
                        bookmarks?: number;
                        clicks?: number;
                        comments?: number;
                        engagement?: number;
                        follows?: number;
                        hahas?: number;
                        impressions?: number;
                        likes?: number;
                        loves?: number;
                        negative_feedback?: number;
                        outbound_clicks?: number;
                        page_likes?: number;
                        pin_clicks?: number;
                        playback_0_count?: number;
                        playback_100_count?: number;
                        playback_25_count?: number;
                        playback_50_count?: number;
                        playback_75_count?: number;
                        profile_activity?: number;
                        profile_visits?: number;
                        quotes?: number;
                        reach?: number;
                        reactions?: number;
                        reactions_by_emoji?: { [key: string]: number };
                        replys?: number;
                        retwets?: number;
                        saved?: number;
                        saves?: number;
                        share?: number;
                        shareMentions?: number;
                        shares?: number;
                        sorrys?: number;
                        url_link_clicks?: number;
                        user_profile_clicks?: number;
                        video_views?: number;
                        views?: number;
                        wows?: number;
                    };
                    stats_updated_date?: string;
                    text?: string;
                    title?: string;
                    url?: string;
                    visibility?: "public"
                    | "unlisted"
                    | "private";
                }
            )[];
            source?: {
                event?: { date?: string; name?: string };
                id_account_catalog?: string;
                id_integration_catalog?: string;
                images?: { description?: string; id_upload?: string }[];
                products?: {
                    description?: string;
                    external_id?: string;
                    id_upload?: string;
                    name?: string;
                    permalink?: string;
                    price?: string;
                }[];
                text?: string;
                url?: string;
            };
            state: | "pending"
            | "generating"
            | "generated"
            | "validated"
            | "failed"
            | "cancelled";
            template?: | "standard"
            | "from_images"
            | "from_text"
            | "from_catalog"
            | "campaign";
            warnings?: {
                code: number;
                data?: { [key: string]: unknown };
                message: string;
            }[];
        },
    >

  • Acepta el plan: las drafts generadas SIN errores pasan a ready y a partir de ahí las publica el robot como cualquier publicación programada.

    Sólo desde generated (error 2102 en cualquier otro estado). Las drafts que sí tienen errores se quedan en draft: se arreglan o se borran con pv.publications.

    Parameters

    • idClient: string
    • idOrganization: string
    • idAiPlan: string
    • options: RequestOptions = {}

    Returns Promise<
        {
            _id: string;
            accounts: string[];
            archived_date?: string;
            attempts: number;
            creation_date: string;
            credits_spent: number;
            destinations?: {
                destination: {
                    id?: string;
                    name?: string;
                    section_id?: string;
                    section_name?: string;
                };
                id_account: string;
            }[];
            error?: {
                code: number;
                data?: { [key: string]: unknown };
                message: string;
            };
            generation_end_date?: string;
            id_client: string;
            id_organization: string;
            keycloak_identifier?: string;
            options: {
                allow_images: boolean;
                gallery_uploads: string[];
                language: string;
                link?: string;
                max_images?: number;
                publish_days: number[];
                shared: boolean;
                timezone: string;
                tone?: string;
                use_organization_context: boolean;
                week_start: string;
            };
            orchestrator_result?: Record<string, never>;
            organization_context?: {
                audience?: string;
                avoid?: string;
                blog_url?: string;
                brand_name?: string;
                default_tone?: string;
                description?: string;
                keywords?: string[];
                notes?: string;
                products?: string;
                sector?: string;
                shop_url?: string;
                social_urls?: string[];
                value_proposition?: string;
                website?: string;
            };
            prompt: string;
            publications: (
                | string
                | {
                    _id: string;
                    ai_generated?: { image: boolean; text: boolean };
                    creation_date: string;
                    destination?: {
                        id?: string;
                        name?: string;
                        section_id?: string;
                        section_name?: string;
                    };
                    engagement_base?: "reach"
                    | "impressions"
                    | "followers";
                    external_identifier?: string;
                    extra_data?: { [key: string]: unknown };
                    files: {
                        _id: string;
                        ai_generated?: {
                            generated_at: string;
                            id_ai_plan?: string;
                            model: string;
                            provider: string;
                        };
                        cover_image?: { _id: string; ai_generated?: { generated_at: string; id_ai_plan?: string; model: string; provider: string; }; cover_image?: ...; cover_offset?: number; creation_date: string; file_externals: { external_identifier: string; external_url: string; social_network: "facebook" | ... 12 more ... | "pinterest"; }[]; ... 6 m...;
                        cover_offset?: number;
                        creation_date: string;
                        file_externals: {
                            external_identifier: string;
                            external_url: string;
                            social_network: | "facebook"
                            | "instagram"
                            | "linkedin"
                            | "tiktok"
                            | "twitter"
                            | "whatsapp"
                            | "youtube"
                            | "google_business"
                            | "bluesky"
                            | "discord"
                            | "telegram"
                            | "threads"
                            | "slack"
                            | "pinterest";
                        }[];
                        file_format: "mp4"
                        | "jpeg"
                        | "gif"
                        | "png"
                        | "jpg";
                        file_properties: {
                            allowed_social_networks: string[];
                            aspect_ratio: { text: string; value: number };
                            duration: number;
                            height: number;
                            size_in_bytes: number;
                            width: number;
                        };
                        file_type: "video"
                        | "image";
                        id_organization: string;
                        is_temporal: boolean;
                        name: string;
                        public_path: string;
                    }[];
                    id_account: | string
                    | {
                        _id: string;
                        creation_date: string;
                        error_code: number;
                        extra_data?: { is_personal_profile?: (...)
                        | (...)
                        | (...) } & { [key: string]: unknown };
                        followers_count?: number;
                        id_client: string;
                        id_organization: string;
                        image?: string;
                        name: string;
                        next_comments_update?: string;
                        next_stats_update?: string;
                        private_message_link?: string;
                        social_network:
                            | "facebook"
                            | "instagram"
                            | "linkedin"
                            | "tiktok"
                            | "twitter"
                            | "whatsapp"
                            | "youtube"
                            | "google_business"
                            | "bluesky"
                            | "discord"
                            | "telegram"
                            | "threads"
                            | "slack"
                            | "pinterest";
                        username?: string;
                    };
                    id_integration?: string;
                    id_organization: string;
                    link?: string;
                    made_for_kids?: boolean;
                    metrics?: {
                        clicks?: number;
                        comments?: number;
                        engagement?: number;
                        followers?: number;
                        followers_gained?: number;
                        impressions?: number;
                        likes?: number;
                        profile_views?: number;
                        reach?: number;
                        saves?: number;
                        shares?: number;
                        video_views?: number;
                    };
                    name?: string;
                    next_stats_update?: string;
                    pending_publish?: {
                        data?: { [key: string]: unknown };
                        deadline?: string;
                        next_check?: string;
                        temp_keys?: string[];
                    };
                    publication_errors: {
                        code: number;
                        data?: { [key: string]: unknown };
                        message: string;
                    }[];
                    publication_type: | "profile"
                    | "page"
                    | "group"
                    | "reels"
                    | "stories"
                    | "message";
                    publication_warnings?: {
                        code: number;
                        data?: { [key: string]: unknown };
                        message: string;
                    }[];
                    publish_date?: string;
                    reply_control?: | "everyone"
                    | "accounts_you_follow"
                    | "mentioned_only"
                    | "followers_only";
                    retries: number;
                    social_network: | "facebook"
                    | "instagram"
                    | "linkedin"
                    | "tiktok"
                    | "twitter"
                    | "whatsapp"
                    | "youtube"
                    | "google_business"
                    | "bluesky"
                    | "discord"
                    | "telegram"
                    | "threads"
                    | "slack"
                    | "pinterest";
                    state: "ready"
                    | "withErrors"
                    | "sended"
                    | "draft"
                    | "publishing";
                    statistics?: {
                        angers?: number;
                        bookmarks?: number;
                        clicks?: number;
                        comments?: number;
                        engagement?: number;
                        follows?: number;
                        hahas?: number;
                        impressions?: number;
                        likes?: number;
                        loves?: number;
                        negative_feedback?: number;
                        outbound_clicks?: number;
                        page_likes?: number;
                        pin_clicks?: number;
                        playback_0_count?: number;
                        playback_100_count?: number;
                        playback_25_count?: number;
                        playback_50_count?: number;
                        playback_75_count?: number;
                        profile_activity?: number;
                        profile_visits?: number;
                        quotes?: number;
                        reach?: number;
                        reactions?: number;
                        reactions_by_emoji?: { [key: string]: number };
                        replys?: number;
                        retwets?: number;
                        saved?: number;
                        saves?: number;
                        share?: number;
                        shareMentions?: number;
                        shares?: number;
                        sorrys?: number;
                        url_link_clicks?: number;
                        user_profile_clicks?: number;
                        video_views?: number;
                        views?: number;
                        wows?: number;
                    };
                    stats_updated_date?: string;
                    text?: string;
                    title?: string;
                    url?: string;
                    visibility?: "public"
                    | "unlisted"
                    | "private";
                }
            )[];
            source?: {
                event?: { date?: string; name?: string };
                id_account_catalog?: string;
                id_integration_catalog?: string;
                images?: { description?: string; id_upload?: string }[];
                products?: {
                    description?: string;
                    external_id?: string;
                    id_upload?: string;
                    name?: string;
                    permalink?: string;
                    price?: string;
                }[];
                text?: string;
                url?: string;
            };
            state: | "pending"
            | "generating"
            | "generated"
            | "validated"
            | "failed"
            | "cancelled";
            template?: | "standard"
            | "from_images"
            | "from_text"
            | "from_catalog"
            | "campaign";
            warnings?: {
                code: number;
                data?: { [key: string]: unknown };
                message: string;
            }[];
        },
    >